I need make all of my posts update. I use bulk upload for store, but in web page posts/products dont show, when i hit update, posts/products are showed up.
I think use wordpress default update function:
// Update post 37
$my_post = array();
$my_post['ID'] = 37;
$my_post['post_content'] = 'This is the updated content.';
// Update the post into the database
wp_update_post( $my_post );
But how to get in arrays all posts id?
Here you go, you just loop through the posts with a foreach.
/*
Plugin Name: Example
Description: This is not just a plugin, it's <em>CODE</em>..
Author:
*/
add_action('init','example_hide');
function example_hide(){
$my_posts = get_posts( array('post_type' => 'post', 'numberposts' => 10 ) );
foreach ( $my_posts as $my_post ):
$my_post['post_content'] = 'This is the updated content.';
wp_update_post( $my_post );
endforeach;
}
You should be able to use WordPress' get_posts
function. Try:
$all_posts = get_posts('numberposts=');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With