SHARE
TWEET

Menampilkan List Update Terbaru di WP

pustakakoran Sep 30th, 2018 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Code in functions.php
  2. =====================
  3. function wpb_lastupdated_posts() {
  4.  
  5. // Query Arguments
  6. $lastupdated_args = array(
  7. 'orderby' => 'modified',
  8. 'ignore_sticky_posts' => '1'
  9. );
  10.  
  11. //Loop to display 5 recently updated posts
  12. $lastupdated_loop = new WP_Query( $lastupdated_args );
  13. $counter = 1;
  14. $string .= '<ul>';
  15. while( $lastupdated_loop->have_posts() && $counter < 5 ) : $lastupdated_loop->the_post();
  16. $string .= '<li><a href="' . get_permalink( $lastupdated_loop->post->ID ) . '"> ' .get_the_title( $lastupdated_loop->post->ID ) . '</a> ( '. get_the_modified_date() .') </li>';
  17. $counter++;
  18. endwhile;
  19. $string .= '</ul>';
  20. return $string;
  21. wp_reset_postdata();
  22. }
  23.  
  24. //add a shortcode
  25. add_shortcode('lastupdated-posts', 'wpb_lastupdated_posts');
  26.  
  27.  
  28.  
  29. Theme:
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36. https://www.wpbeginner.com/wp-tutorials/how-to-display-a-list-of-last-updated-posts-in-wordpress/
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top