Slider in category page

Posted in: Newspaper
Post count: 66

Hi, how can I get a slider to autoplay in a category page? Also how can I show only unique posts on category page (i.e., if a post is showing up in the slider, how can I have it NOT show up below)?

Thanks!

Post count: 3343

Hi,
Add this code: 'autoplay' => '2', like here: http://screencast.com/t/VzmO8sMs

Add this code in functions.php and change that 98 with your featured category ID

add_action( 'pre_get_posts', 'be_exclude_category_from_blog' );
function be_exclude_category_from_blog( $query ) {

    if( $query->is_main_query() && $query->is_category() ) {
        $query->set( 'cat', '-98' );
    }
}

Thanks!

Post count: 66

Thanks Marius, I’ll give it a try. I assume it’s possible to do this for more than one category?

Serg

Post count: 854

hi,
use coma between values: http://screencast.com/t/EYH2T8fAwcjG

Thanks for you message.
Radu A.

Post count: 42
add_action( 'pre_get_posts', 'be_exclude_category_from_blog' );
function be_exclude_category_from_blog( $query ) {

    if( $query->is_main_query() && $query->is_category() ) {
        $query->set( 'cat', '-98' );
    }
}

Please, add this function to the theme panel.

Post count: 854

hi,

thanks ingilizcecin for your answer.

Thanks for you message.
Radu A.

Post count: 15

I feel making the category slider auto play and unique is a main feature as it doesnt do its job otherwise and looks messy. will you be making this standard in the future as it will finish off the catergory page?

Post count: 1291

Hi,

We’ll think about this, thank you for your suggestion.

Have a nice day, Emil G.

Post count: 21

Hi tagDiv,

My Featured category ID = 2

I using bellow code in file functions.php themes (i append code end of file)

add_action( ‘pre_get_posts’, ‘be_exclude_category_from_blog’ );
function be_exclude_category_from_blog( $query ) {

if( $query->is_main_query() && $query->is_category() ) {
$query->set( ‘cat’, ‘-2’ );
}
}

but it not working exclude post in featured.

my post added 2 categories: cars and featured.

when load site, i see post at featured and cars.

best regards,

Post count: 6600

Hi,

Please make sure you add the code like this: http://screencast.com/t/dU6XKtP4
Paste the code from below into the functions file:

add_action( 'pre_get_posts', 'be_exclude_category_from_blog' );
function be_exclude_category_from_blog( $query ) {

    if( $query->is_main_query() && $query->is_category() ) {
        $query->set( 'cat', '-2' );
}
}

I have tested this and works fine, when viewing the featured category page the posts should show only in the slider as we have excluded the featured category http://screencast.com/t/GxyXjEG9y55
If you want other category excluded add the category id like this http://screencast.com/t/EYH2T8fAwcjG

Hope this helps!
Thanks

Post count: 38

Hi,

So I wish to do this for all 4 of my categories, and you mentioned I have to change “98” for my “featured category ID”…

I don’t know where I can find my ID’s?

Post count: 6600

Hi,

You can go to WordPress Dashboard > posts > categories and hover over one category, the ID of that category will be showed at the bottom of the page, like this: http://screencast.com/t/55R3fQwgydA

Thanks

Post count: 38

I did your above steps and I get this error…

http://s16.postimg.org/urcepu10l/watdaaaa.jpg

I don’t understand why this stuff happens to me.. It’s like this theme hates me with a passion.

Please help.

Post count: 1291

Hi,

The code for should look like this:

add_action( 'pre_get_posts', 'be_exclude_category_from_blog' );
function be_exclude_category_from_blog( $query ) {

    if( $query->is_main_query() && $query->is_category() ) {
        $query->set( 'cat', '-44' );
    }
}

Make sure you copy it properly, let me know if it works.

Thank you, Emil G.

Post count: 38

Hi Emil,

It did not work…

I get the same error: Fatal error: Call to undefined function add_action() in /home/leadnrr/public_html/wp-includes/functions.php on line 4632

And Line 4632 is: add_action( ‘pre_get_posts’, ‘be_exclude_category_from_blog’ );

Btw, my Featured category ID is actually : 44, because I erased the Featured category in the beginning not knowing why it was there in the first place.

Post count: 6600

Hi,

Replied via e-mail!
Thanks

Post count: 38

Hi Lucian,

Actually, I don’t think I got the email, please contact me again via: kevinhan123@hotmail.com

Thank you

Post count: 6600

Hi,

You have to add that code into theme’s function.php file which you can find in the root of theme files: http://screencast.com/t/X5iuZk1qXXRm
Please make sure you add this right you have added the code into functions.php file found in WordPress’s files that’s why you got that error.

Thanks

Viewing 18 posts - 1 through 18 (of 18 total)
The forum ‘Newspaper’ is closed to new topics and replies.