srikat

Untitled

Aug 17th, 2016
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. <?php
  2.  
  3. add_action( 'genesis_before_loop', 'sk_latest_post', 15 );
  4. function sk_latest_post() {
  5. // WP_Query arguments
  6. $args = array (
  7. 'cat' => get_query_var( 'cat' ),
  8. 'no_found_rows' => true,
  9. 'posts_per_page' => '1',
  10. );
  11.  
  12. // The Query
  13. $query = new WP_Query( $args );
  14.  
  15. // The Loop
  16. if ( $query->have_posts() ) {
  17. while ( $query->have_posts() ) {
  18. $query->the_post();
  19. // do something
  20. the_title();
  21. }
  22. } else {
  23. // no posts found
  24. }
  25.  
  26. // Restore original Post Data
  27. wp_reset_postdata();
  28. }
  29.  
  30. genesis();
Advertisement
Add Comment
Please, Sign In to add comment