Archived topic
Adding "read more" to excerpts only on blog page
3 replies · Started by Ben on September 8, 2020
Viewing posts 1–4 of 4
Hi, I'm using this code to modify excerpts:
add_filter( 'wp_trim_excerpt', 'tu_excerpt_metabox_more' );
function tu_excerpt_metabox_more( $excerpt ) {
$output = $excerpt;
if ( has_excerpt() ) {
$output = sprintf( '%1$s <p class="read-more-container"><a class="read-more button" href="%2$s">%3$s</a></p>',
$excerpt,
get_permalink(),
__( 'Read more', 'generatepress' )
);
}
return $output;
}
Is there a way to target this just on the blog page, eg
if ( has_excerpt() && is_front_page() )
?
Hi there,
The conditional tag depends on if you your blog page is the front page or not.
See the explanation here:
https://codex.wordpress.org/Conditional_Tags#The_Blog_Page
Let me know if this helps :)
Thanks Leo, you're right, it was is_home() I should have used.
Many thanks
Ben
No problem :)
This archived topic is closed to new replies.