[wp-hackers] Plugin to update all posts in a category

Callum Macdonald lists.automattic.com at callum-macdonald.com
Thu Mar 1 13:40:53 GMT 2007


Does anyone know how I can use get_posts('category=x'); to get all 
current and future posts? Or can I use another function to do this easily?

For my plugin I want to work on all posts in a given category, both 
published and unpublished.

Cheers - Callum.

Aaron Brazell wrote:
>
>
> On Feb 25, 2007, at 11:20 PM, Callum Macdonald wrote:
>
>> G'day,
>>
>> I'm working on a plugin to update the custom fields of an entire 
>> category of posts in one go.
>>
>> For example, I have a category called photos to which I add all posts 
>> that have photos. If I wanted to add a new tag to these posts (stored 
>> in a custom field) then I'd go to my plugin page, select the 
>> category, and choose the option, "add a tag to this category".
>>
>> I'm having a few challenges that I'd appreciate any pointers on.
>>
>> 1) I'd like to list the categories as a drop down menu, so one can be 
>> selected, with the category id as the value. I''m looking at the 
>> wp_list_categories function, but I don't think that's what I want.
>
> wp_dropdown_categories() perhaps?
>
>>
>> 2) I want to get a list of all the post ids from a single category. 
>> Again I'm looking at template tags, but I'm sure there must be a 
>> better way.
>
> get_posts('category=x') ... where x is the cat_ID?
>
>>
>> 3) I plan to use a foreach loop to circle through each post and then 
>> use the update_post_meta() function. Any feedback on this approach 
>> would be great.
>
> No feedback. It seems reasonable enough to me... Good luck!
>
>
>
> Aaron
>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>



More information about the wp-hackers mailing list