Wordpress

WordPress: Change Sidebar Format

Goals

  • Truncate the Recent Post’s Length
  • Add the post id (may be unsafe), ideally I would like to add another sequence (separate from the post id), but for now I’ll just add the post id (no time for the former) because I want to have a numeric reference for each published post
  • Add a Hyphen for formatting purposes
  • Add […] at the end for formatting purposes

 

Solution

  • Go to:
    • /wp-includes/widgets/class-wp-widget-recent-posts.php
    • On line 98 change:

$post_title = get_the_title( $recent_post->ID );

TO

$post_title = $recent_post->ID.” – “.substr(get_the_title( $recent_post->ID ), 0, 20).” […]”;

 

Leave a Reply

Your email address will not be published. Required fields are marked *