Site logo

Archived topic

Missing Read-More-Button in Search-Results

13 replies · Started by Alex M. on January 22, 2021

Viewing posts 1–14 of 14

Hi there,

I put a "read-more"-tag in my posts. Additional the excerpt-length in the customizer is set to 30 words.
This works well on category-pages. The "Read More"-Button appears on all excerpts.

But it does not work in search results. If the "read-more"-tag is set before the 30 words, no "Read More"-Button appears on the excerpt.
On Excerpts without manual "read-more"-tag or the tag after 30 words it works fine.

I found this documentation:
https://docs.generatepress.com/article/activating-read-custom-excerpt/
Is this related to search-results as well?
If yes, where do I put the snippet in?

Thank you,
Alex

Hi there,

The Customizer Excerpt Length applies to the automatic excerpt that WP Generates.
When using the More Tag, you require either one of those PHP snippets ( text or button ) in order to display the read more.

This article explains how to add PHP:

https://docs.generatepress.com/article/adding-php/

Hi David,

thank you for your reply.
Unfortunately the snippets do not help in this case.
I tried them yesterday already in the functions.php and now via the code snippets plugin.

It is still the same output.

Edit: I should mention I use the Glossary Plugin.
It has these "special posts"(?), but they look and feel like regular posts.
Is there any variable in the snippet, that refers to the post type?

Can you share a link to your site where i can see the issue?

Sure,
the website is: hotelfach-lexikon.de

I posted a normal post with a more-tag and it has the same output.
The search result is cut at the "more"-Position but no "read more"-button appears.

You can search for the normal post with "lorem".
You can search "vip" to see more posts of the glossary plugin.
Both searches show the issue with no "read more"-button while a "more"-position in the post.

Hi there,

Are you using the More Tag in the editor, or are you using the custom excerpt metabox?

Can you show us a screenshot of the editor for that post?

Do you have any custom functions added to the site? If so, can you temporarily deactivate them one by one to see if one of them is conflicting with the theme? The read more text/button should appear automatically when the More Tag is in use.

Meanwhile I think it is normal?!
I tested in different themes and experienced this behaviour even in WP-Standard-Themes like twenty twenty one.
In Search Results appears no Read-More-Button if the More-Tag is used.

I still do not know if it is a bug or a feature?
And why is no one else irritated about this? I checked half of the internet ...

I guess I need to put the Button manually in the results-loop.
Is there by any chance a snippet for this?

Thank you very much for your help and time! I really appreciate this!
But this issue looks like non-GP-related.

Alex

It should actually appear by default.

For example, here's one of our sites in the Site Library: https://gpsites.co/marketer/?s=fast

Something on your site must be telling it not to - either a plugin or a custom function would be my guess.

Yes, it appears by default after 20 words(?) or the value I am able to define in the GP-Customizer. So far so good.

BUT if you set a more-Tag before 20 words the search result will be cut at the defined tag position and no "read more"-Button appears in my experience on two sites with several themes.

The search results shouldn't even care that there's a More tag, as they're set to display the excerpt (not the content), and the More tag only applies to the content.

You could try doing this:

add_filter( 'generate_show_excerpt', function( $show ) {
    if ( is_search() ) {
        return false;
    }

    return $show;
} );

Thank you, Tom!
With this Snippet the missing button appears.
On the other hand the buttons on search results without more-Tag disappear.
But since I plan to add the tag in every post this will solve my individual question, I guess. I just need to remember ...

Thank you very much, my problem is solved. :)

Take care,
Alex

Glad I could help :)

This archived topic is closed to new replies.