Using the Results shortcode as a custom results page

Custom results page via the results shortcode

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.

Preparation

For this to work, two things are required

  • A search instance created

  • A page or a post or any custom post type you wish to use

Step 1 - Place the search results shortcode to the page you created

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..)

Step 2 - Search instance configuration

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.

Step 3 - Set up the 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:

mydomain.com/my-results-page/

Now, take only the link path without the domain section, so in our case

my-results-page/

..and add the ?asp_s={phrase} query parameter to it, so it becomes:

my-results-page/?asp_s={phrase}

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.

Step 4 - Test

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

Last updated

Copyright Ernest Marcinko