• Anyone know how to keep a single category of posts from showing up in a homepage JFlow slider? My choices in the theme are to select All Categories to display, or to select a single category. I want to select all BUT ___.

    I have tried to exclude in the slider.php them by category number but it’s not working.

    <?php $recent = new WP_Query(“cat=” .ot_option(‘slider_cat&exclude=21,209,73’). “&showposts=” .ot_option(‘slider_num’) ); while($recent->have_posts()) : $recent->the_post();?>

Viewing 2 replies - 1 through 2 (of 2 total)
  • If you added the ‘exclude=21,209,73’ there, then I think I know the solution.

    Change the code to this…

    <?php $recent = new WP_Query("cat=" .ot_option('slider_cat'). ",-21,-209,-73&showposts=" .ot_option('slider_num') ); while($recent->have_posts()) : $recent->the_post();?>

    Not having looked at the plugins code, I’m guessing the plugin has an options page for category IDs, which is saved in the variable ot_option[‘slider_cat’]

    Since that variable should just be a string of numbers, all you should have to do is add ,-21,-209,-73 after the .ot_option(‘slider_cat’).”

    By adding “exclude=21,209,73” inside the ot_option variable, it will break your query.

    Hopefully that works for you!

    You could also accomplish this by adding the tax_query parameter to the WP_Query arguments

    See https://codex.www.ads-software.com/Class_Reference/WP_Query#Taxonomy_Parameters

    Using the operator argument you can specify NOT IN example below:

    'tax_query' => array( 'taxonomy' => %tax_name%, 'field' => 'id', 'terms' => %terms_string _or_array%, 'operator' => 'NOT IN' )

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to exclude a single category from slider’ is closed to new replies.