[Resolved] Changing search results page display

Home Forums Support [Resolved] Changing search results page display

Home Forums Support Changing search results page display

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1244688
    Ricardo

    Hi,

    I am doing a site about Portuguese popular and traditional knowledge that has been converted into phrases. I think in english you call it saying, aphorism or maxim. Let’s call it “saying”.

    I managed a way to show them in category and tags page nicely and I would like to replicate that on search page.

    category page

    https://anexim.pt/category/proverbios-da-regiao-de-valpacos/

    Basically I’ve hidden the post title via css (because sometimes the sayings are poems and I cannot have them properly written in a post title) and configure the archive page to show the full content.

    1- Would it be possible to have exactly the same output and display with the search results?

    – Full content (in the content I write with a bigger font size the saying itself + one explanation)
    – categories+tags

    2- Would it be possible to work a post title so that it could be shown like a poem?

    Homem do Minho
    Calça de pau
    Veste de linho
    E come pão de passarinho.

    This way I could use post title + excerpt

    Thanks in advance,
    Ricardo

    #1244824
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    You can tell the search results to show the full content like this:

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

    Can you show me what the title looks like now vs what you’d want it to look like?

    Let me know 🙂

    #1244991
    Ricardo

    Hi,

    Thank you for your reply.

    I copied the entire code you gave me and paste it on snippets and unfortunately it’s not changing anything.

    I also created a plugin with the code, but it’s not affecting the display.

    About the post title I only have problems when it’s at poem. I cannot split it in verses (different lines), or can I?

    For example,

    But everyone
    on the island of music
    in the city of drumbeats
    believed that only…

    Instead of

    But everyone on the island of music in the city of drumbeats believed that only…

    Thanks,
    Ricardo

    #1245568
    Tom
    Lead Developer
    Lead Developer

    Sorry about that – just updated the function above so it should work.

    Adding line breaks to the title isn’t an easy thing to do, unfortunately. It may be worth to continue hiding the actual title when it’s a poem. You can even try the “Aside” post format.

    #1245809
    Ricardo

    Hi,

    Thanks for your reply and tip.

    Now the function worked great and got what I desired.

    Do you have any suggestion on where to learn this kind of things?

    Thanks,
    Ricardo

    #1245951
    Leo
    Staff
    Customer Support

    generate_show_excerpt is a theme filter:
    https://docs.generatepress.com/article/generate_show_excerpt/

    Filters allow you to use a simple function to overwrite values, whether they’re options or even text on your site:
    https://docs.generatepress.com/article/using-filters/

    The if ( is_search() ) is a conditional tag:
    https://codex.wordpress.org/Conditional_Tags

    Let me know if this helps 🙂

    #1246586
    Ricardo

    Thank you for your explanation! It is great to understand a little more this science or art 🙂

    Best regards,
    Ricardo Pons

    #1247056
    Leo
    Staff
    Customer Support

    No problem 🙂

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.