Created
May 23, 2016 20:05
-
-
Save cogdog/35d2b8c377b568bd7b161316828f89f4 to your computer and use it in GitHub Desktop.
Daily Blank Seed Counts
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
<ol> | |
<?php | |
// This will back create the response counts and generate some random visit counts | |
// for 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, | |
'post_type' => 'post', | |
'post_status' => 'publish', | |
); | |
$myposts = get_posts( $args ); | |
foreach ( $myposts as $post ) { | |
setup_postdata( $post ); | |
// get the right tag so we can find the responses | |
$dailyblank_tag = get_post_meta( $post->ID, 'dailyblank_tag', 1 ); | |
// query to get sll responses | |
$responses_count_query = new WP_Query( | |
array( | |
'posts_per_page' =>'-1', | |
'post_type' => 'response', | |
'hashtags'=> $dailyblank_tag, | |
) | |
); | |
// store total count of all responses | |
$response_count = $responses_count_query->post_count; | |
// now update the number of examples | |
update_post_meta( $post->ID, 'response_count', $response_count); | |
$randy = rand(10, 100); | |
//update visit counts | |
update_post_meta($id, 'daily_visits', $randy); | |
echo '<li>' . $dailyblank_tag . ' responses: ' . $response_count . ' and visit count set to ' . $randy . '</li>'; | |
wp_reset_postdata(); | |
} | |
?> | |
</ol> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment