Archived topic
Remove excerpt (entry-summary) on CPT archive page
10 replies · Started by Fabien on March 3, 2022
Hi,
Is there a function to fully remove entry-summary on an archive page ? I've tried add_filter( 'generate_show_excerpt', '__return_false' );, it removes entry-summary but displays entry-content instead (the full post).
Thanks
Hi Fabien,
You can try create a block element - content template that doesn't include content or excerpt, and assign it to your CPT archive:https://docs.generatepress.com/article/block-element-content-template/
Is that the only way ?
Using a block element – content template is the easiest way.
Or you need to install a child theme, take a copy of the content.php and archive.php to your child theme folder, rename them, eg. content-yourcpts.phpand archive-yourcpt.php.
https://docs.generatepress.com/article/using-child-theme/
Remove this part from content-yourcpts.php
<div class="entry-summary"<?php echo $itemprop; // phpcs:ignore -- No escaping needed. ?>>
<?php the_excerpt(); ?>
</div>
In archive-yourcpt.php file, Replace this line generate_do_template_part( 'archive' ); with get_template_part( 'content', 'yourcpts' );
There isn't a function to easily do that like you can do with the featured image ?
add_filter( 'option_generate_blog_settings', function( $options ) {
if ( is_tax( 'modele_cat' ) ) {
$options['post_image'] = false;
}
return $options;
});
Hi there,
you can try setting the excerpt length to 0 - see here for an example:
https://docs.generatepress.com/article/excerpt_length/#examples
If I am correct, that doesn't remove the entry-summary div :-(
Correct.
If you must remove the <div> then the methods Ying provided are the only way to do that today.
Ok noted ! Would be great to be able to remove the <div> using a function. Maybe something to add to the next roadmap ?
Its on our list :)
Awesome, thanks @David !