Using the Results shortcode as a custom results page
Custom results page via the results shortcode
Last updated
Custom results page via the results shortcode
Last updated
Please note, that this method should not be used as replacement of the default WordPress results page - rather an addition to a custom single page.
For this to work, two things are required
A search created
A page or a post or any custom post type you wish to use
Open up the page or the preferred CPT in the wordpress editor. Copy the results shortcode from the search instance options to the page content. (see screenshots below)
The search bar must be visible on that same page for this to work. You can either add the search bar above the results shortcode, or use it in a different location on this custom page (header, widget, sidebar etc..)
Make sure to publish the page and take note of it's url, as we are goint to use it in just a minute. Navigate back to the search isntance options and go to the General Options -> Logic and behaviour
panel.
Scroll down to the Trigger and Redirection section, and select the magnifier and return button actions to redirect to a custom URL.
This is the most important step. Take the URL of the results page you created earlier in step 1. In our case it was:
Now, take only the link path without the domain section, so in our case
..and add the ?asp_s={phrase} query parameter to it, so it becomes:
That's it! This is the custom URL we need. Let's finish the setup. Go back to the redirection options and copy/paste this URL to the custom redirect URL field.
Go to the site front-end, and try searching for something and hit the Return or Magnifier buttons. The search will redirect to the page with the results shortcode, trigger itself and display the results.
If it does not work then:
Make sure the search bar is present on the custom results page, it is required, without it this will not work
Clear all your site cache