[Support request] Page Hero – Post excerpts

Home Forums Support [Support request] Page Hero – Post excerpts

Home Forums Support Page Hero – Post excerpts

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #744817
    rockett

    I want to have the page hero pull the featured image / pst title & Post excerpt.
    I can’t seemed to find the tags for that?

    #744830
    David
    Staff
    Customer Support

    Hi there,

    do you want to display the auto excerpt generated by WP or the one you add to the Excerpt meta?

    #744831
    rockett

    Hi David,
    Either is fine but I guess Excerpt Meta would make more sense for control

    #744847
    David
    Staff
    Customer Support

    So probably best to just output if a Custom Excerpt exists. And we can create a short code for that like so:

    function db_page_hero_excerpt() {
        ob_start();
        global $post;
        if ( has_excerpt( $post->ID ) ) {
        ?>
        <div class="page-hero-excerpt">
            <?php echo the_excerpt(); ?>
        </div>
        <?php
        }
        return ob_get_clean();
    }
    add_shortcode( 'page_hero_excerpt','db_page_hero_excerpt' );

    https://docs.generatepress.com/article/adding-php/

    Once you have that added to theme, then use this shortcode in the hero:

    [page_hero_excerpt]

    #746850
    rockett

    Works a treat sir, thanking you kindly…
    Now I just need to work out why the read more button disappears if I use custom excerpts.

    #746853
    David
    Staff
    Customer Support

    Awesome. Could try echoing the permalink as well πŸ™‚

    echo '<a href="'.get_permalink().'">Read More</a>';

    #746865
    rockett

    OK so I followed the instructions to re add the read more buttons when using manual excerpts.. But, it now adds them to the page hero.
    I guess I need to comment them out or similar?

    #746866
    rockett
    #746867
    David
    Staff
    Customer Support

    Aah sorry my bad, i did wonder why you would want the read more in the page hero πŸ™‚
    This should still work:

    https://generatepress.com/forums/topic/how-to-display-read-more-when-using-the-excerpt-field/#post-297608

    #746874
    rockett

    No the first route worked well for the front page posts just below the Lets Work section…. but it also adds it to the post Page Hero with the manual excerpt.
    Is there some kind of filter I can add to the page hero to not show Read More there?

    #746883
    David
    Staff
    Customer Support

    Right if you’re using the filter that was provide here https://generatepress.com/forums/topic/how-to-display-read-more-when-using-the-excerpt-field/#post-297608 then you could omit it from being displayed on single pages by changing:

    if ( has_excerpt() ) {

    to this:

    if ( has_excerpt() && !is_single() ) {

    #746888
    rockett

    Bloody Marvellous.
    You guys rule really.
    I can’t wait to finish converting my site and then start making videos to sell GeneratePress

    #746980
    David
    Staff
    Customer Support

    Awesome – Love to see people really leveraging GP’s Elements. And please do share when you have started recodeding πŸ™‚

    #756731
    rockett

    Guys I really have enjoyed creating my site in GeneratePress and after doing several edits and css add ons I am really happy with both the function and speed I am scoring on chrome’s lighthouse and pingdom.
    I have also moved a couple of clients over to GeneratePress and will continue to fly the flag so to speak!
    Well done.

    My site if you fancy a look: https://rockett.co

    #756738
    David
    Staff
    Customer Support

    Thanks for the great feedback. Site looks great – love what you done with the archive layout and post cards. Thanks for sharing.

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