Add the Excerpt to Recent Posts

X Theme and Pro Theme12 Comments

The Recent Posts element in Cornerstone are admittedly lean, but one simple change you can make is to add the post excerpt to them.

While this is something that gets asked frequently, and the code needed to achieve it has been posted by Themeco, many can benefit by having it here. We’re much easier to find than a forum search!

Here’s how you can add excerpts into recent posts.

The following code should be placed in your functions.php file inside your x-child theme.

Furthermore, it’s good to understand how something functions. The code above works by removing the recent posts shortcode from WordPress, and re-initializing it with a new function that pulls the post excerpt from the database and places it into the post box. Finally, you can use CSS to customize the look and feel of the text simply by targeting the .x-recent-posts-excerpt class.

12
Leave a Reply

avatar
  Subscribe  
Notify of
Amy
Amy

When I tried this, I received a “fatal error”:

Fatal error: Call to undefined function csl18n() in /nfs/c03/h06/mnt/56870/domains/MYWEBSITE/html/wp-content/themes/x-child/functions.php on line 93

This is the only thing I have added to the child theme.

Kevin
Kevin

Hi!
I was wondering if there was a way to pull in the categories too? I tried just modifying what you have here, but it just pulls text that says “ARRAY”. I haven’t been able to find anything on the forums about adding categories to the recent posts widget.

Erlend
Erlend

Hi Micheal.

Is there a way to choose the length of the excerpt?

Thanks

Stuart Borders
Stuart Borders

I have a custom post type of ‘recipes’ that I want to use this for, is there a way to include this PT in the available options for the recent posts.