Created
January 31, 2017 01:03
-
-
Save hearvox/ff635df4ba43245b9361e7a0d1aaa81d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Update postdate for all post in a category */ | |
// Get IDs of all posts in a category. | |
$args = array( | |
'category_name' => 'cat-name', | |
'fields' => 'ids', | |
); | |
$query = new WP_Query($args); | |
// Update meta for all IDs. | |
$meta_id = 0; | |
if ( $query->have_posts() ) { | |
foreach( $query->posts as $post_id ) { | |
$meta_id = update_post_meta( $post_id, 'meta-key-name', 'Meta Value'); | |
// Print ID and returns. | |
// echo "$post_id - $meta_id\n"; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment