Site logo

Archived topic

Read More formatting in RSS feed with Manual Excerpt

16 replies · Started by Alexander on September 22, 2020

Viewing posts 1–15 of 17

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.

Thanks, Tom. Unfortunately, I don't have a test/staging site.

If 3.0 final isn't too far away anymore I'll just wait.

We're about 2 weeks away from the final version. Can you share the excerpt-related functions you're using at the moment?

Sure.

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.

I 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 );

Thank you, Tom - just to make sure, this is an additional code snippet and doesn't replace the existing ones, right?

That's correct - it's the default in 3.0, so you can remove it when you choose to update.

Hello 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.

Hi 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?

Right, 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).

If 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.

No problem - sorry that it slipped by :)

Hello 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. :P

Cheers
Alex.

This archived topic is closed to new replies.