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

Aaron Brazell abrazell at b5media.com
Mon Feb 26 04:27:15 GMT 2007



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



More information about the wp-hackers mailing list