Is is possible to exclude posts from the blog category from the slideshow?
In loop-slider.php you have a query_posts()
function, add the following key to the arguments array: 'cat' => '-1,-2,-3'
. Replace the numbers with the IDs of the categories you want to exclude.
The following code does not work: ‘-1,-2,-4’); ?>
Am I doing something wrong? The slider does not display, and navigation is not shown.
-
This reply was modified 12 years, 5 months ago by Maaaatt.
Edit: I have now achieved this with a front page category excluder plugin.
I’m trying to do this myself, I can’t get it to work, Maaatt what did you do to get it to work?
Can you please post what you did and where in the code?
Is there a code that can query what code(s) to INCLUDE not exclude?
I figured it out, used WP Filter Post Category Plugin
For those who don’t want to get a plugin, here’s the code change:
in loop-slider.php, look for this code:
$args = array(
'posts_per_page' => 4,
'paged' => $paged,
'ignore_sticky_posts' => 1
);
Yours may look slightly different if you changed the # of posts per page already. In my case, I wanted to ONLY use category #9, so I changed it to:
$args = array(
'posts_per_page' => 4,
'paged' => $paged,
'ignore_sticky_posts' => 1,
'cat' => 9
);
Note the extra comma after the ‘previously-last’ line!
If you want to exclude categories, you’d use the directions above, but instead of : ‘cat’ => 9 you’d use: ‘cat’ => ‘-1,-2,-3’