Created
July 13, 2013 17:21
-
-
Save alexkingorg/5991415 to your computer and use it in GitHub Desktop.
Find all posts in converted categories and threads and add a "projects" category to them.
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 | |
function akv3_add_projects_cat() { | |
// find all posts in converted categories and threads | |
$term_ids = array(400, 417, 438, 455, 13, 14, 15, 20, 22, 52, 53, 58, 59); | |
$query = new WP_Query(array( | |
'posts_per_page' => -1, | |
'tax_query' => array( | |
array( | |
'taxonomy' => 'projects', | |
'field' => 'id', | |
'terms' => $term_ids, | |
'operator' => 'IN' | |
) | |
) | |
)); | |
// add "projects" cat to those posts | |
foreach ($query->posts as $post) { | |
wp_set_object_terms($post->ID, 'projects', 'category', true); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment