<?php
// Get all posts by custom taxonomy
$a = get_posts(array(
'showposts' => -1, // you can try and test run this by setting a pagination value of higher than 1.
'post_type' => 'post',
'tax_query' => array(
array(
'taxonomy' => 'taxonomy-name',
'field' => 'name',
'terms' => array('taxonomy-slug'))
),
'orderby' => 'ID',
'order' => 'ASC')
);
$posts = array();
// Generate array of post IDs
foreach ( $a as $post ) {
$posts[] += $post->ID;
}
// Feed post array into wp_update_post
foreach ( $posts as $post_id ) {
$arg = array(
'ID' => $post_id,
);
wp_update_post( $arg );
}
Get posts by custom taxonomy and resave them programmatically
In