Archived topic
Blocked articles show excerpt
5 replies · Started by Streater on October 1, 2021
I have blocked articles for members. But it doesn't show the excerpt. I also don't want the excerpt showing on the Blog page.
I tried this:
https://generatepress.com/forums/topic/remove-excerpt-from-archive-page-and-add-excerpt-to-single-post/
Is there anyway to show the excerpt on the post and not the blog?
On the Customizer I did set the excerpt word count to 0. I also used the PHP from the post link above.
Hi there,
you could use a Block Element - and add the GP Dynamic Content Block and set it to excerpt.
Then set the hook for where you want it displayed
I do have a header element already for posts.
I tried using <?php the_excerpt(); ?> in that for the excerpt but that didn't work.
You can't add PHP to a Header Element.
Use a Hook Element with that PHP, set the Hook to generate_after_header and its priority to 25
Hmmmmm. Doesn't seem to be working.
I created this hook:
<?php
add_action( 'generate_after_header','excerpt_function_name' );
function excerpt_function_name() {
the_excerpt();
}
On the Elements I chose Hook: Custom Hook ; Execute PHP checkbox checked ; Priority: 25 ; Location : Post Category : Newsroom
Your function in the hook element should only be this line:
<?php the_excerpt(); ?>
So something like this:
https://www.screencast.com/t/t7TK8C7FgL