Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Dailyblank Fix Missing Author Tags
<ol>
<?php
// This was needed to fix a Daily Blank bug where the author twitter handles were not properly
// added to a Daily blank site. Insert into the magic spot of page-debug.php, go to /debug on your
// site, let it do its work, then remove.
$args = array(
'posts_per_page' => -1,
'meta_key' => 'wAuthor',
'post_type' => 'post',
'post_status' => 'publish',
);
$myposts = get_posts( $args );
foreach ( $myposts as $post ) {
setup_postdata( $post );
// do we have an author?
$wAuthor = get_post_meta( $post->ID, 'wAuthor', 1 );
echo '<li>Fixing tags for "' . $post->post_title . '" adding tag for ' . $wAuthor . '</li>';
// add author to new terms if we have one, otherwise just use the tag
$newterms = ( $wAuthor ) ? $post->post_name . ',' . $wAuthor : $post->post_name;
wp_set_post_terms( $post->ID, $newterms, 'post_tag' );
wp_reset_postdata();
}
?>
</ol>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.