This support ticket is created hace 3 años, 1 mes. There's a good chance that you are reading advice that it now obsolete.
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.
Sun
Mon
Tue
Wed
Thu
Fri
Sat
-
9:00 – 12:00
9:00 – 12:00
9:00 – 12:00
9:00 – 12:00
9:00 – 12:00
-
-
13:00 – 18:00
13:00 – 18:00
13:00 – 18:00
14:00 – 18:00
13:00 – 18:00
-
Supporter timezone: America/Jamaica (GMT-05:00)
Este tema contiene 7 respuestas, tiene 2 mensajes.
Can you tell me how I customize the built-in WordPress search results page. For example:
enlace oculto
Please note you won't be able to access that URL without modifying your hosts file. I've attached a screenshot for further reference. Thanks, and I apologize if this is covered in documentation somewhere - I couldn't seem to find anything on the subject.
Thank you for getting in touch. The wordpress default search page is actually an archive. In order to customize it you will need to create a custom archive at Toolset -> WordPress Archives and then select Search Results. See Screenshot
Thanks - that was helpful. So I have Relevanssi Premium installed on the site, which offers a lot of features such as ordering search results, highlighting search words that hit, etc. How do I take advantage of these features when using a custom search archive?
How do I take advantage of these features when using a custom search archive?
Given that this is a Relevanssi then I wouldn't be equipped to say how to do this. My best recommendation would be to get in touch with the relevanssi support team to see how best they can assist with this one.
If I could push just a little further, Toolset requires Relevanssi be installed, so I thought you may have some more insight into this. I'm assuming when using text-based search filters in Toolset that it uses Relevanssi's engine? I can reach out to them about the highlight features, but I would assume that the search logic would at least work as configured in Relevanssi. Do you know of any way to order results by Relevanssi's default order-by? Looks like by using a Toolset content template that you're forcing it to use something else, like title, date, etc.?
In terms of the highlight feature they would be better equipped to handle that as it would've needed to support custom templates.
Do you know of any way to order results by Relevanssi's default order-by?
When I checked relevanssi they only have 2 ordering which is by post date and by relevance. The relevance attribute is a default ordering attribute of wordpress archives so you should be able to write a custom hook to overwrite the Toolset ordering.
So something like this.
add_action( 'pre_get_posts', 'my_change_sort_order');
function my_change_sort_order($query){
if(is_archive()):
//If you wanted it for the archive of a custom post type use: is_post_type_archive( $post_type )
//Set the order ASC or DESC
$query->set( 'order', 'ASC' );
//Set the orderby
$query->set( 'orderby', 'relevance' );
endif;
};
Thanks - I'll take a look at using that custom code. My only question is regarding the note on needing to change is_archive() if it's a custom post type. In this particular example, the archive is the "search results" archive, so would include all post types that allow being included in global searches. Would this part of the code need to change?
My only question is regarding the note on needing to change is_archive() if it's a custom post type.
You can perhaps add the is_search() parameter as well to determine if its an archive and a search archive like below.
add_action( 'pre_get_posts', 'my_change_sort_order');
function my_change_sort_order($query){
if(is_archive() && is_search()):
//If you wanted it for the archive of a custom post type use: is_post_type_archive( $post_type )
//Set the order ASC or DESC
$query->set( 'order', 'ASC' );
//Set the orderby
$query->set( 'orderby', 'relevance' );
endif;
};