• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Modifying the excerpt on a post list page

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › Modifying the excerpt on a post list page

This topic is: resolved

Tagged: Excerpt, filter

  • This topic has 6 replies, 2 voices, and was last updated 10 years, 2 months ago by Chris Cree.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • January 5, 2013 at 5:03 pm #9809
    theMikeD
    Participant

    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 #9835
    Chris Cree
    Participant

    You 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 #9848
    theMikeD
    Participant

    Geez, 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 #9853
    Chris Cree
    Participant

    Genesis 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 #9858
    theMikeD
    Participant

    function 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 #9860
    theMikeD
    Participant

    Ahh, 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
    Chris Cree
    Participant

    Sweet. Glad you were able to get it sorted.

  • Author
    Posts
Viewing 7 posts - 1 through 7 (of 7 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2023 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble