- This topic has 16 replies, 2 voices, and was last updated 3 years, 2 months ago by Alexander.
-
AuthorPosts
-
September 22, 2020 at 7:19 pm #1454660Alexander
Hi,
about a year ago you helped me with some Code Snippets to always use the Manual Excerpt together with the Read More button, and this all works quite well (for reference: https://generatepress.com/forums/topic/manual-excerpt-is-ignored/)
Recently (after I switched my “follow by email” functionality away from Jetpack to a Mailchimp automation using the RSS feed) I notice that, when I do have a Manual Excerpt, the formatting is a bit mangled.
Namely, the text “Read More” and the linked post title are concatenated into one, like “Read MorePost Title”. This wouldn’t seem like a big deal, but in the emails (they’re based on the RSS feed item), the link doesn’t work (maybe because it contains the “#more” thing?).
Here’s my RSS feed, which contains items without and with a Manual Excerpt:
https://www.alex-kunz.com/feed/Any help on where to look and how to fix this would be appreciated.
Thanks!
Alex.September 23, 2020 at 9:58 am #1455764TomLead DeveloperLead DeveloperHi Alex,
Any chance you’re willing to try out 3.0-beta?: https://generatepress.com/generatepress-3-0-a-new-era/
I believe this issue is fixed in that version.
Let me know π
September 23, 2020 at 10:01 am #1455771AlexanderThanks, Tom. Unfortunately, I don’t have a test/staging site.
If 3.0 final isn’t too far away anymore I’ll just wait.
September 23, 2020 at 10:04 am #1455784TomLead DeveloperLead DeveloperWe’re about 2 weeks away from the final version. Can you share the excerpt-related functions you’re using at the moment?
September 23, 2020 at 10:34 am #1455820AlexanderSure.
First one, to use the Manual Excerpt over the automatic one:
add_filter( 'generate_show_excerpt', function( $excerpt ) { if ( has_excerpt() ) { return true; } return $excerpt; } );
Second one, to add the Read More button to the Manual Excerpt:
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; }
Thanks!
Alex.September 23, 2020 at 3:32 pm #1456118TomLead DeveloperLead DeveloperI think updating to 3.0 is your best bet, but you can try this:
add_filter( 'generate_content_more_link_output', function() { return sprintf( '<p class="read-more-container"><a title="%1$s" class="read-more content-read-more" href="%2$s" aria-label="%4$s">%3$s</a></p>', the_title_attribute( 'echo=0' ), esc_url( get_permalink( get_the_ID() ) . apply_filters( 'generate_more_jump', '#more-' . get_the_ID() ) ), __( 'Read more', 'generatepress' ), sprintf( /* translators: Aria-label describing the read more button */ _x( 'More on %s', 'more on post title', 'generatepress' ), the_title_attribute( 'echo=0' ) ) ); }, 50 );
September 23, 2020 at 5:59 pm #1456210AlexanderThank you, Tom – just to make sure, this is an additional code snippet and doesn’t replace the existing ones, right?
September 24, 2020 at 9:15 am #1457269TomLead DeveloperLead DeveloperThat’s correct – it’s the default in 3.0, so you can remove it when you choose to update.
October 9, 2020 at 7:26 am #1480392AlexanderHello Tom,
I updated to GP3 now, but find the behavior of the Read More/Manual Excerpt connection unchanged, ie. I still need to have both of the Code Snippets that I pasted above active in order to a) get my Manual Excerpt over the auto-excerpt, and b) see the Read More button when this Manual Excerpt override is active.
The RSS feed also still shows the Read MorePost Title concatenation for those articles that do NOT have a Manual Excerpt set.
Am I missing some new setting or something?
Thanks
Alex.October 9, 2020 at 11:03 am #1480907TomLead DeveloperLead DeveloperHi there,
Looks like we need to update the function in GP Premium as well to use aria-label instead of screen reader text.
wp_trim_excerpt
will likely always be necessary – this isn’t something we can introduce without affecting existing sites.What is the
generate_show_excerpt
filter doing, exactly?October 9, 2020 at 1:00 pm #1481057AlexanderHello Tom, you gave me that filter in your message https://generatepress.com/forums/topic/manual-excerpt-is-ignored/#post-992403 π
October 9, 2020 at 1:40 pm #1481120TomLead DeveloperLead DeveloperRight, so it’s to overwrite the more tag functionality.
All of this is still necessary (minus the screen-reader-text thing, which we’ll fix in GPP).
October 9, 2020 at 1:43 pm #1481127AlexanderIf the screen-reader-text thing is what will fix the “Read MorePost Title” thing in the RSS feed then that’ll make me happy. π
Thanks.
October 10, 2020 at 9:42 am #1482272TomLead DeveloperLead DeveloperNo problem – sorry that it slipped by π
February 12, 2021 at 6:37 am #1655716AlexanderHello Tom & support team,
it’s been a while and unfortunately, the bug with the formatting of the “Read More” link in RSS still exists… I understand that this isn’t a high priority thing but figured I’d post a gentle nudge. π
Cheers
Alex. -
AuthorPosts
- You must be logged in to reply to this topic.