Last active
June 7, 2018 14:07
-
-
Save aishahenderson/3ff92e8a526964cb3dab0550c81a9d4b to your computer and use it in GitHub Desktop.
WP Update Post
This file contains hidden or 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 get_header(); ?> | |
| <div id="primary" class="content-area"> | |
| <main id="main" class="site-main"> | |
| <?php | |
| $update_today = date("Y-m-d",mktime(0,0,0,date("m"),date("d"),date("Y"))); | |
| $postArgs= array( | |
| 'post_type' => 'prime_activities', | |
| 'post_parent' => 0, | |
| 'meta_key' => 'release_date', | |
| 'post_status' => 'publish', | |
| 'meta_query' => array( | |
| 'relation' => 'AND', | |
| array( | |
| 'key' => 'approved', | |
| 'value' => true, | |
| 'compare' => '=', | |
| ), | |
| array( | |
| 'key' => 'expire_date', | |
| 'value' => $update_today, | |
| 'type' => 'DATE', | |
| 'compare' => '>=', | |
| ) | |
| ), | |
| 'date_query' => array( | |
| array( | |
| 'after' => 'January 1st, 2017', | |
| /*'before' => array( | |
| 'year' => 2013, | |
| 'month' => 2, | |
| 'day' => 28, | |
| ), | |
| 'inclusive' => true,*/ | |
| ), | |
| ), | |
| 'post_status' => 'publish', | |
| 'posts_per_page' => -1 | |
| ); | |
| $postReq= new WP_Query($postArgs); | |
| foreach($postReq->posts as $my_post) { | |
| $updated_post_info = array( | |
| 'ID' => $my_post->ID, | |
| 'pinged' => '', | |
| 'comment_status' => 'open' | |
| ); | |
| wp_update_post($updated_post_info); | |
| } | |
| ?> | |
| </main><!-- #main --> | |
| </div><!-- #primary --> | |
| <?php | |
| get_sidebar(); | |
| get_footer(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment