Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function update_my_metadata(){
- $args = array(
- 'post_type' => 'post', // Only get the posts
- 'post_status' => 'publish', // Only the posts that are published
- 'posts_per_page' => -1 // Get every post
- );
- $posts = get_posts($args);
- foreach ( $posts as $post ) {
- // Run a loop and update every meta data
- update_post_meta( $post->ID, 'post_views_count', '0' );
- }
- }
- // Hook into init action and run our function
- add_action('init','update_my_metadata');
Advertisement
Add Comment
Please, Sign In to add comment