Override default template of search results
- techniquepixParticipant3 years, 1 month ago #27308
Hi,
Is it possible to easily override the default template of the search results ?
I would like to edit the wpsolr-templates/twig/ files, but not directly in plugin folder. For example I want to remove the meta informations block in search/result.twig file.
Is there a way to do this ?Thanks for your help
Best regards
wpsolrKeymaster3 years, 1 month ago #27309I’d like to emphasis that the WPSOLR search template is deprecated and not supported. Instead, your theme’s search template is recommended (you can select it in screen 2.1).
On the other hand, the suggestions’ twig templates are supported. You can find a full example in /wpsolr-examples.
techniquepixParticipant3 years, 1 month ago #27317Hi,
The search was displayed via the shortcode [solr_search_shortcode]. Can I still use it ? Or is it deprecated too ?
If it’s still ok, there is no way to easily customize the html of the results render ?
If not, I will use the default search of WP.Thanks
wpsolrKeymaster3 years, 1 month ago #27318Indeed, the shortcode [solr_search_shortcode] is using WPSOLR’s search twig templates, and is deprecated.
The idea instead is to use WPSOLR’s search backend while enjoying 100% of your theme’s search features.
WPSOLR provided the shortcode a long time ago, for a simple blog post search.
But now, there is simply no need of replacing advanced search templates like Flatsome/WooCommerce.If you choose “Use my theme’s search template” in screen 2.1, you will need no more the shortcode: all your theme’s archive templates will be used as usual to display results coming from WPSOLR’s backend (Elasticsearch, Solr, or Algolia, and soon Weaviate AI semantic search).
techniquepixParticipant3 years, 1 month ago #27319Ok, thanks for your clarifications !
Last question : is it working with Elementor ? I created a search results template with Elementor, inserted the “Post Archive” widget but the results displayed are not the same as when I don’t use Elementor Template. With Elementor template it displays CPT that I haven’t added to WPSOLR index. Is there a specific configuration for Elementor ?Thanks
wpsolrKeymaster3 years, 1 month ago #27320With Elementor template it displays CPT that I haven’t added to WPSOLR index
It works with Elementor archive templates, not with single page Elementor templates.
More generally, WPSOLR can replace archive queries.You can find a 100K products WooCommerce demo with Elementor “Hello” theme: https://www.wpsolr.com/wpsolr-demos/
techniquepixParticipant3 years, 1 month ago #27321Yes, I added a template of type “Search results”, it’s not a single page Elementor template.
But when I search a item, it displays the results like if WPSOLR was not activated ( = the results of default WP search).
For example in WPSOLR index posts of type “posts”, “pages”, “cpt-1” are selected in screen 2.2 as data to index. But on front the search results displays posts of type “cpt-2”, a post type that I haven’t added to the WPSOLR index.
And it’s the case only when I activate the search result template from Elementor. If I use the search.php template from my theme, the search only displays posts from “posts”, “pages” and “cpt-1”, so only the post types I have indexed with WPSOLR. Posts from “cpt-2” are not displayed. It’s the expected behaviour.
I don’t know how to fix this so that it works with the search results template of Elementor…Thanks
techniquepixParticipant3 years, 1 month ago #27326Yes, I see it. I have “WPSOLR facets” widget and “WPSOLR sort list” widget.
But I don’t use them.techniquepixParticipant3 years, 1 month ago #27331I have no errors, neither in the console nor in debug.log.
And yes I used the “Archive posts” widget.I noticed that the “No. of results per page” parameter of WPSOLR is working fine, even with Elementor template. If I update the value in admin, the number of posts on front is correct. It’s only the displayed post types that is not correct. It displays types that I haven’t added to WPSOLR index.
techniquepixParticipant3 years, 1 month ago #27333Unfortunately it didn’t change anything… I still have post types that I don’t want in the search with Elementor.
If no solution, I’ll use the theme template and not the Elementor template…
You must be logged in to reply to this topic.