[Resolved] Page hero using excerpt without tag?

Home Forums Support [Resolved] Page hero using excerpt without tag?

Home Forums Support Page hero using excerpt without tag?

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1298047
    Greg

    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
    Greg

    #1298060
    Greg

    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() {
        ob_start();
      
        echo get_the_excerpt(); 
      
        return ob_get_clean();
    } );

    Thanks
    Greg

    #1298355
    Leo
    Staff
    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.