Community Forums › Forums › Design Tips and Tricks › Modifying the excerpt on a post list page
This topic contains 6 replies, has 2 voices, and was last updated by Chris Cree 4 months, 2 weeks ago.
-
AuthorPosts
-
January 5, 2013 at 5:03 pm #9809
By default, home.php displays the excerpt for a post and the featured image. How can I add something to the beginning of the excerpt text? Specifically, I’d like the date of the post to show up as in an old-skool newspaper byline. For example:
“7 May 2012 – Lorum ipsum….”
Is there a filter or something I can use? I don’t see anything appropriate listed in the filter reference.
January 5, 2013 at 7:58 pm #9835You can do that with a combination of modifying the post info section and css. If you use the Simple Edits plugin you can use this shortcode in the post info section:
[post_date format="j F Y" after=" - "]
Then you can just use the appropriate CSS to position that at the beginning of the first paragraph of text.
Edit: I missed that you are asking about the excerpt. It might be easier for you to use manual excerpts and add the date to the excerpt field.
January 5, 2013 at 8:37 pm #9848Geez, I hope not! There must be a way to filter the excerpt and insert the date in there!
January 5, 2013 at 8:51 pm #9853Genesis uses the WordPress function the_excerpt() for excerpts. I don’t see a filter listed for the excerpt content itself. But if you research it you may find someone who has done it already.
Short of that, I’d try my initial suggestion about changing the post info and use the content limit instead on your home page.
January 5, 2013 at 9:04 pm #9858function md_add_dateline( $content ) {
return “HELLO”;
}
add_filter( ‘the_excerpt ‘, ‘md_add_dateline’);According to the docs, that should filter the excerpt and replace it with “HELLOO” but it does not. But once I figure it out, I think that’ll be the way to go.
January 5, 2013 at 9:36 pm #9860Ahh, an extra space killed me. This code does the trick:
function md_add_dateline( $content ) {
$d = the_date('',"", ": ", true);
return str_replace ('',$p, $content);
}
add_filter( 'the_excerpt', 'md_add_dateline');
January 5, 2013 at 10:45 pm #9882 -
AuthorPosts
You must be logged in to reply to this topic.