Site logo

Archived topic

Page Hero - Post excerpts

14 replies · Started by rockett on November 30, 2018

Viewing posts 1–15 of 15

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?

Hi there,

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

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

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]

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.

Awesome. Could try echoing the permalink as well :)

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

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?

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?

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

Awesome - Love to see people really leveraging GP's Elements. And please do share when you have started recodeding :)

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

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

This archived topic is closed to new replies.