pustakakoran

Menampilkan Latest Update

Oct 9th, 2017
99
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CARA 1:
  2.  
  3. Langsung pastekan kode berikut di theme wp:
  4. <?php $u_time = get_the_time('U');
  5. $u_modified_time = get_the_modified_time('U');
  6. if ($u_modified_time >= $u_time + 86400) {
  7. echo "<p>Last modified on ";
  8. the_modified_time('F jS, Y');
  9. echo " at ";
  10. the_modified_time();
  11. echo "</p> "; } ?>
  12.  
  13. Tampilanny:
  14. Last modified on October 9th, 2017 at 12:24
  15.  
  16. CARA 2 >> Muncul Otomatis Sebelum Content:
  17.  
  18. Paste di function.php:
  19. function wpb_last_updated_date( $content ) {
  20. $u_time = get_the_time('U');
  21. $u_modified_time = get_the_modified_time('U');
  22. if ($u_modified_time >= $u_time + 86400) {
  23. $updated_date = get_the_modified_time('F jS, Y');
  24. $updated_time = get_the_modified_time('h:i a');
  25. $custom_content .= '<p class="last-updated">Last updated on '. $updated_date . ' at '. $updated_time .'</p>';
  26. }
  27. $custom_content .= $content;
  28. return $custom_content;
  29. }
  30. add_filter( 'the_content', 'wpb_last_updated_date' );
  31.  
  32. Paste di style.css:
  33. .last-updated {
  34. font-size: small;
  35. text-transform: uppercase;
  36. background-color: #fffdd4;
  37. }
RAW Paste Data