Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. <?php
  2. function show_post_of_the_day( $query ) {
  3.  
  4. if ( $query->is_home() && ! is_admin() && $query->is_main_query() ) {
  5.  
  6. $today = getdate();
  7.  
  8. $args = array(
  9. 'post_type' => 'post',
  10. 'date_query' => array(
  11. array(
  12. # 'year' => 2012,
  13. 'month' => $today['mon'],
  14. 'day' => $today['mday'],
  15. ),
  16. ),
  17. );
  18. $new_query = new WP_Query( $args );
  19.  
  20. $permalink = home_url('/');
  21. while( $new_query->have_posts() ) {
  22. $new_query->the_post();
  23.  
  24. $permalink = get_permalink();
  25. } wp_reset_postdata();
  26.  
  27. #echo $permalink;
  28. header( 'Location: '. $permalink );
  29. }
  30.  
  31. } add_action( 'pre_get_posts', 'show_post_of_the_day' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement