I have used the populate-posts method to pre-populate a drop-down field with Post titles. What I would like to do would be to exclude 1 of 9 categories from the drop-down. Specific advice on how to do this?
Thanks!
I have used the populate-posts method to pre-populate a drop-down field with Post titles. What I would like to do would be to exclude 1 of 9 categories from the drop-down. Specific advice on how to do this?
Thanks!
What code are you using currently to do this? You will have to change how you pull posts to exclude categories you want excluded. I would have to see how you are grabbing posts first though to be able to help as there are multiple ways to grab post titles.
This is the code that I am using. If you could help me with specific syntax, that would be much appreciated. I want to exclude a category called "Guides".
So if you look at the documentation on the get_posts function in WordPress, you will see that it includes options for excluding categories:
http://codex.wordpress.org/Template_Tags/get_posts
I think you have to do it by the category numbers, and it will take a list of comma separated values if memory serves me.
Here's what worked for me, using the category argument and placing a minus symbol in front of the category ID.
$posts = get_posts('numberposts=-1&post_status=publish&category=-12,-1&orderby=title&order=ASC');
Glad you figured it out.