Guest User

Untitled

a guest
Jan 21st, 2020
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. function update_my_metadata(){
  2. $args = array(
  3. 'post_type' => 'post', // Only get the posts
  4. 'post_status' => 'publish', // Only the posts that are published
  5. 'posts_per_page' => -1 // Get every post
  6. );
  7. $posts = get_posts($args);
  8. foreach ( $posts as $post ) {
  9. // Run a loop and update every meta data
  10. update_post_meta( $post->ID, 'post_views_count', '0' );
  11. }
  12. }
  13. // Hook into init action and run our function
  14. add_action('init','update_my_metadata');
Advertisement
Add Comment
Please, Sign In to add comment