[Resolved] Page hero using excerpt without tag?

Home Forums Support Page hero using excerpt without tag?

  • This topic has 2 replies, 2 voices, and was last updated 5 months ago by Leo.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #1298047

    Hi guys

    Is there anyway to pull the post excerpt into a header hero element using this method but without the <p> tag it’s wrapped in?

    I’ve been adding non breaking spaces to the excerpt itself to help with word wrapping on smaller screens so can’t strip out the HTML altogether, but want to keep it in the H tag I have already setup and styled rather than it being a <p> tag in the header.

    The only way I’ve been able to do this until now is using the plugin Shortcodes Ultimate and [su_post field=”post_excerpt”], but it is throwing up a PHP warning, and I would rather do it through a snippet if at all possible.

    Thanks for your time


    Ah ha, found a way. thought I would post here incase anyone else is looking for this in the future!
    Apparently get_the_excerpt makes the difference 🙂

    add_shortcode( 'page_hero_excerpt', function() {
        echo get_the_excerpt(); 
        return ob_get_clean();
    } );


    Customer Support

    GLad you’ve figured out 🙂

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.