Skip to content

Instantly share code, notes, and snippets.

@abrudtkuhl
Created September 11, 2014 18:21
Show Gist options
  • Save abrudtkuhl/71c82d4cc3f99032ddce to your computer and use it in GitHub Desktop.
Save abrudtkuhl/71c82d4cc3f99032ddce to your computer and use it in GitHub Desktop.
WordPress Swap All Pages In Custom Taxonomy To Another Category
add_action( 'init', 'update_taxonomy');
function update_taxonomy() {
$posts = get_posts(
array(
'post_type' => 'page',
'posts_per_page' => -1,
'tax_query' => array(
array(
'taxonomy' => 'content_category',
'field' => 'slug',
'terms' => 'news-releases'
)
)
)
);
foreach ($posts as $post) {
wp_set_object_terms($post->ID, 'featured', 'content_category');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment