[Resolved] Missing Read-More-Button in Search-Results

Home Forums Support [Resolved] Missing Read-More-Button in Search-Results

Home Forums Support Missing Read-More-Button in Search-Results

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #1629914
    Alex M.

    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

    #1630149
    David
    Staff
    Customer Support

    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/

    #1630164
    Alex M.

    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?

    #1630483
    David
    Staff
    Customer Support

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

    #1630499
    Alex M.

    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.

    #1630637
    Tom
    Lead Developer
    Lead Developer

    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?

    #1630645
    Alex M.

    Hi Tom,

    I use the More Tag in the Editor.
    Here is the Screenshot:
    https://hotelfach-lexikon.de/wp-content/uploads/Bildschirmfoto-2021-01-23-um-19.10.20.png

    #1631616
    Tom
    Lead Developer
    Lead Developer

    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.

    #1631693
    Alex M.

    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

    #1631922
    Tom
    Lead Developer
    Lead Developer

    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.

    #1632455
    Alex M.

    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.

    #1633154
    Tom
    Lead Developer
    Lead Developer

    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;
    } );
    #1634046
    Alex M.

    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

    #1634514
    Tom
    Lead Developer
    Lead Developer
Viewing 14 posts - 1 through 14 (of 14 total)
  • You must be logged in to reply to this topic.