- This topic has 31 replies, 12 voices, and was last updated 5 years, 4 months ago by Leo.
-
AuthorPosts
-
October 18, 2017 at 2:09 pm #405848Mark
Having spent quite some time troubleshooting this (before finally searching here – duh!!!), it’s good that there is an explanation.
However, given that this has come up before from a number of folks and has caused some confusion, is it reasonable to expect that the theme might handle this in a more robust/predictable way in a future release, to avoid others going down this same path?
Thank you.
October 18, 2017 at 11:46 pm #406032TomLead DeveloperLead DeveloperGlad it helped!
I wish WP itself had a better way of handling this. I’ll look into it some more and will come up with something solid enough for the theme 🙂
February 1, 2018 at 1:46 pm #485888JakobHI Tom,
I’ve absolutly no clue, where to put:
add_filter( ‘wp_trim_excerpt’, ‘tu_excerpt_metabox_more’ );
function tu_excerpt_metabox_more( $excerpt ) {
$output = $excerpt;if ( has_excerpt() ) {
$output = sprintf( ‘%1$s Read more‘,
$excerpt,
get_permalink()
);
}return $output;
}in order to get a “read more” – Button while using excerpt field in Blog view.
February 1, 2018 at 4:34 pm #485995LeoStaffCustomer SupportMake sure you use the second block of code here:
https://docs.generatepress.com/article/activating-read-custom-excerpt/with one of these methods: https://docs.generatepress.com/article/adding-php/
May 20, 2018 at 1:17 am #579888PascalHi
And for those ones who are looking for (like me), to have a button with the link text what has been set as the ‘Read more label’ in the Customiser :add_filter( 'wp_trim_excerpt', 'tu_excerpt_metabox_more' ); function tu_excerpt_metabox_more( $excerpt ) { $output = $excerpt; $settings = wp_parse_args( get_option( 'generate_blog_settings', array() ), generate_blog_get_defaults() ); 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(), wp_kses_post( $settings['read_more'] ) ); } return $output; }
May 20, 2018 at 9:24 am #580162LeoStaffCustomer SupportAwesome thanks for sharing!
May 31, 2018 at 4:55 pm #589176RobertI’d like to use the code above in https://generatepress.com/forums/topic/how-to-display-read-more-when-using-the-excerpt-field/#post-370520. By default it ends up at the right after my handcrafted excerpt. How do I style it so that it’s in a separate block so I can center it under the excerpt, apply padding, etc.
May 31, 2018 at 9:07 pm #589258LeoStaffCustomer SupportIs this for adding read more when using custom excerpt field?
If so I think the button one is what you are looking for more:
https://docs.generatepress.com/article/activating-read-custom-excerpt/June 1, 2018 at 4:49 am #589419RobertHi Leo,
Yes, I’m using a custom excerpt. I’m trying to mimic the way the Site Library’s Classic theme centers “Read More” under the excerpt. In looking over the reference you posted, I see I need to add the p class called read-more-container to my Read More link snippet.
Thanks!
June 1, 2018 at 9:22 am #589652LeoStaffCustomer SupportNo problem!
June 7, 2018 at 9:36 am #594214Christian ZumbrunnenIt’s just fantastic I could find help so easily here!
Thanks Tom.
GeneratePress and your support is just incredible fantastic!When “Display read more as button” is checked the “read more” link is enclosed by a
<p class="read-more-container"
…</p>
How could I accomplish that this is rendered the same way here?
June 7, 2018 at 9:38 am #594216Christian ZumbrunnenSorry, it was up there and I overlooked it.
June 7, 2018 at 1:14 pm #594397LeoStaffCustomer SupportGlad you figured out!
October 30, 2018 at 11:40 pm #715161Kemoseems like the classes for the button changed a bit? updated code that works for me(add to child’s functions.php):
//fix read more button with manual excerpts field add_filter( 'wp_trim_excerpt', 'tu_excerpt_metabox_more' ); function tu_excerpt_metabox_more( $excerpt ) { $output = $excerpt; $settings = wp_parse_args( get_option( 'generate_blog_settings', array() ), generate_blog_get_defaults() ); 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(), wp_kses_post( $settings['read_more'] ) ); } return $output; }
October 31, 2018 at 9:41 am #715703LeoStaffCustomer SupportIt shouldn’t. This code doesn’t work?
https://docs.generatepress.com/article/activating-read-custom-excerpt/#read-more-button -
AuthorPosts
- The topic ‘How to display 'read more' when using the excerpt field’ is closed to new replies.