Update all posts - wordpress -
i have looked @ this thread , tried implement given code sample there;
//code snippet mass update posts add_action('init','mass_update_posts'); function mass_update_posts(){ $all_posts = get_posts('numberposts='); $my_posts = get_posts( array('post_type' => 'post', 'numberposts' => $all_posts ) ); foreach ( $my_posts $my_post ): wp_update_post( $my_post ); endforeach; } i set code in footer.php doesn't seem anything? missing? used;
$my_posts = get_posts( array('post_type' => 'post', 'numberposts' => -1 ) ); but didn't help either...
let me see if understand trying code...
first every time loads page footer.php fire want mass update of posts loop of post itself?
there 1000000 things wrong trying code.
never add together actions in footer file belong in function.php file of theme. your $all_posts variable empty because sending function expecting array of arguments string (please read get_post() function documentation) $all_posts not integer using next line (the get_post() function returns list of wp_post objects. your loop goes through posts , updates them same post, changing nil , accomplishing nothing.so guess real question trying accomplish?
wordpress
No comments:
Post a Comment