- This topic has 7 replies, 3 voices, and was last updated 3 years, 12 months ago by Leo.
-
AuthorPosts
-
April 18, 2020 at 2:09 pm #1244688Ricardo
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.
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+tags2- 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,
RicardoApril 18, 2020 at 5:52 pm #1244824TomLead DeveloperLead DeveloperHi 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 🙂
April 19, 2020 at 1:18 am #1244991RicardoHi,
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,
RicardoApril 19, 2020 at 9:24 am #1245568TomLead DeveloperLead DeveloperSorry 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.
April 19, 2020 at 1:21 pm #1245809RicardoHi,
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,
RicardoApril 19, 2020 at 4:58 pm #1245951LeoStaffCustomer Supportgenerate_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_TagsLet me know if this helps 🙂
April 20, 2020 at 7:34 am #1246586RicardoThank you for your explanation! It is great to understand a little more this science or art 🙂
Best regards,
Ricardo PonsApril 20, 2020 at 12:01 pm #1247056LeoStaffCustomer SupportNo problem 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.