Is there a way to cycle through all existing, published posts on a WP site, that will replicate pushing the "update" button on every post one by one? This would be a one time event. I have a site with thousands of existing posts and there is no way I can go through and hit "update" on every single one of them.
I've added a plugin that will display some new info on each post, but in order for it to work on existing posts, you have to "update" every single post individually.
Thanks
Is there a way to cycle through all existing, published posts on a WP site, that will replicate pushing the "update" button on every post one by one? This would be a one time event. I have a site with thousands of existing posts and there is no way I can go through and hit "update" on every single one of them.
I've added a plugin that will display some new info on each post, but in order for it to work on existing posts, you have to "update" every single post individually.
Thanks
I'm not sure if it will work, but you could try running wp_update_post()
on all posts concerned. It will trigger the save_post
hook.
According to the Codex:
Unlike wp_insert_post(), it is only necessary to pass the ID of the post to be updated and the elements to be updated.
You could try looping an array of post IDs and running the function on them. You can fetch the post IDs using WP_Query.
foreach( $posts_id as $post_id ){
wp_update_post( $post_id );
}
post_content
filter, rather than actually updating the post content. If I installed a plugin and it went and edited every one of my posts I wouldn't be happy. Also, cycling through every post on the site is potentially a slow process and is very likely to time out on large sites or on shared hosts. – John Blackbourn Commented Jul 3, 2014 at 9:19