category_name to exclude posts
-
Hi there,
I am trying to use the category_name parameter to exclude certain posts from showing in the WordPress loop. I can get the desired effect to work using straight up “cat=-4” and targeting the post ID, but I am having trouble getting it to work using the category name.The code also only shows the latest post.
My working code is this:
<?php query_posts("showposts=1" . "&cat=-4"); // show one latest post only ?>
My desired code would be
<?php query_posts("showposts=1" . "&category_name=-All Work"); // show one latest post only ?>
I would even be happy using the category slug, but I can’t figure that out either. Has anyone encountered this before and could point me in the right direction?
Much appreciated.
Ryan
- The topic ‘category_name to exclude posts’ is closed to new replies.