Skip to content

Instantly share code, notes, and snippets.

@cogdog
Created May 23, 2016 20:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cogdog/cf75335cc5d217e1f39382c756c97091 to your computer and use it in GitHub Desktop.
Save cogdog/cf75335cc5d217e1f39382c756c97091 to your computer and use it in GitHub Desktop.
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