- This topic has 9 replies, 2 voices, and was last updated 3 years, 4 months ago by
Leo.
-
AuthorPosts
-
December 6, 2022 at 8:04 am #2451671
Glen
Example Archives Page: https://www.glenhuff.com/category/social-media-best-practices/page/4/
For some reason, none of the blog posts on an archive page have a “Continue Reading” link after the excerpt. I have the label set in the settings under:
Theme > Customize > Blog > Archives > Read more label = “Continue Reading”. Yet, nothing appears. The title links to the single blog posts, but I wanted a read more button after the excerpt. How do I do this?December 6, 2022 at 11:53 am #2451911Leo
StaffCustomer SupportHi there,
Can you take a look this first?
https://docs.generatepress.com/article/excerpt-issues/#read-more-label-or-button-not-showingDecember 6, 2022 at 12:23 pm #2451940Glen
Thank you. I found a link on that page useful. It sent me to this: https://docs.generatepress.com/article/activating-read-custom-excerpt/
I added the following code to the theme-functons.php file and it worked.
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-button-container"><a class="button" href="%2$s">%3$s</a></p>', $excerpt, get_permalink(), __( 'Read more', 'generatepress' ) ); } return $output; }Is this something I’ll have to add every time the theme updates?
December 6, 2022 at 12:33 pm #2451951Leo
StaffCustomer SupportI added the following code to the theme-functons.php file and it worked.
Please do not edit the parent theme’s
function.phpfile.Use one of these methods instead: https://docs.generatepress.com/article/adding-php/
December 6, 2022 at 12:39 pm #2451973Glen
Using a child theme seems like the easiest route. I don’t have one installed. Is there a download for the GP child theme?
December 6, 2022 at 12:48 pm #2451992Leo
StaffCustomer SupportThe Code Snippets plugin suggested is actually the easiest route and the option I would pick if you aren’t using a child theme already.
If you prefer to use a child theme: https://docs.generatepress.com/article/using-child-theme/
December 6, 2022 at 1:25 pm #2452024Glen
Okay, I have the child theme installed. My function to show continue reading buttons with excerpts has been added. The archives look great.
But, now I’m seeing a continue reading button on the single post. The theme I’m using displays the excerpt as the first paragraph in a Hero Full-Width fashion.
Example: https://www.glenhuff.com/how-to-create-a-winning-social-media-strategy/
December 6, 2022 at 1:36 pm #2452043Leo
StaffCustomer SupportCan you edit the function to this instead?
add_filter( 'wp_trim_excerpt', 'tu_excerpt_metabox_more' ); function tu_excerpt_metabox_more( $excerpt ) { $output = $excerpt; if ( has_excerpt() && !is_single() ) { $output = sprintf( '%1$s <p class="read-more-button-container"><a class="button" href="%2$s">%3$s</a></p>', $excerpt, get_permalink(), __( 'Read more', 'generatepress' ) ); } return $output; }December 6, 2022 at 1:45 pm #2452067Glen
Works perfectly! Thank you.
December 6, 2022 at 1:46 pm #2452069Leo
StaffCustomer SupportGlad to help 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.