Update all wordpress posts

后端 未结 2 2025
天涯浪人
天涯浪人 2021-01-13 12:53

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

相关标签:
2条回答
  • 2021-01-13 13:18

    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;
    }
    
    0 讨论(0)
  • 2021-01-13 13:33

    You should be able to use WordPress' get_posts function. Try:

    $all_posts = get_posts('numberposts=');
    
    0 讨论(0)
提交回复
热议问题