Home › Forums › Support › Search result should have same template as custom blog page with query loop
- This topic has 10 replies, 2 voices, and was last updated 3 years, 2 months ago by
David.
-
AuthorPosts
-
February 22, 2023 at 5:49 am #2542489
Dimitri
Hello,
i could easily create a custom blog archive page with query loop (great experience, thank you for this!)
Now, the search result page obviously has default archive layout, which is different.
How can i “magically” display it on the same way as my custom blog archive page with query loop?thank you
February 22, 2023 at 9:24 am #2542910David
StaffCustomer SupportHi there,
when you add a Query Loop to a Loop Template, DO NOT set any Query Parameters, just check the “Inherit Query from Template”.
Then that Elements Display Rules can be set to All Archives and/or Search Results for example. And the one loop element will work for all of them.February 22, 2023 at 10:03 am #2542967Dimitri
Dear David,
i did as you suggested.
Unfortunately, blog page shows now almost nothing and search page shows the layout according to the customizer settings.
Do i still missing something?February 22, 2023 at 10:09 am #2542978David
StaffCustomer SupportCan you make sure that the Query Loop has no Parameters set ? And then activate the “Inherit Query from Template”.
Display rules
Location 1 – >Blog
Location 2 – >Search Resultslet me know
February 23, 2023 at 1:40 am #2543664Dimitri
Dear David,
I am a little confused.
I do not see even the possibility to set Query Loop Parameters when i “activate Inherit Query from Template” – they are disapearing.And what about display rules you mentioned?
I afraid, i need some more explanations…February 23, 2023 at 6:08 am #2543919Dimitri
Dear David,
maybe you meant, i should create a Block Element “Loop Template”, so that will be default template and to use it everywhere i need with “Inherit Query from Template” ?I deed it and it works! But it shows all posts 🙁
So my new questions are:
– by archives: how can i show only posts from current category?
– by search results: how can i show only relevant postthank you for our paticence
February 23, 2023 at 6:27 am #2543952David
StaffCustomer Supportmaybe you meant, i should create a Block Element “Loop Template”, so that will be default template and to use it everywhere i need with “Inherit Query from Template” ?
That is correct.
You must NOT add any Params to the Query Loop block, just activate
Inherit Query from TemplateAs a suggestion i would do:
1. for Display Rules:
All Archivesas this will be used on all taxonomies etc.
2. a separate Element Loop Template for the Search archives, as you may need to add other content before the loop on this page.February 23, 2023 at 7:11 am #2543997Dimitri
Thank you David, it works!
Now i am struggling with missing Archive Title and Search Page Title like “Your results for [keyword]”.
Your hint appreciated.February 23, 2023 at 8:33 am #2544236David
StaffCustomer SupportOK,
so for the Archive Title, add a Headline Block, and in the Blocks Toolbar, use the GP Dynamic Data option to set the Title.
https://docs.generatepress.com/article/dynamic-data/
We will be adding this to a GB update soon.
For the Search Terms, you will need to register a shortcode using this PHP Snippet:
add_shortcode('search_term', function(){ return get_search_query(); });Then you can use a Headline Block and include the
[search_term]shortcode insideFebruary 23, 2023 at 8:47 am #2544249Dimitri
Top, wonderfull, thanks a lot!
February 24, 2023 at 1:46 am #2545093David
StaffCustomer SupportGlad to be of help!
-
AuthorPosts
- You must be logged in to reply to this topic.