Deploying search results to a CPT single page

Forums › Forums › Search & Filter Pro › Deploying search results to a CPT single page

Viewing 5 posts – 1 through 5 (of 5 total)
  • Anonymous
    #270347

    I’ve got my search and filter setup working perfectly on my front page (within Oxygen). It searchs/filters my CPT no problem.

    However when I clicked through to a CPT single page I also have a new searchandfilter form/results here which basically does the same as the front page form but with an hard-coded meta_query to show related CPTs.

    I have search results showing on a page but I can’t seem to action any ordering on it. I believe this is due to the ‘Results URL’. If I hard set the URL to one of my CPT urls then it works but, as you can guess, if I visit a different single page that ordering no longer works as the URL has changed.

    I’ve tried to implement the below on the page but it doesn’t appear to work.

    function dynamic_search_results( $url,  $sfid) {
    	//if search form ID = 225, the do something with this query
    	if($sfid==1636)
    	{
          $url = get_the_permalink();
        }
      return $url;
    }
    add_filter( 'sf_ajax_results_url', 'dynamic_search_results', 10, 2 );

    Can you give some guidance on how to setup a results with a dynamically changing URL.

    Hope the above makes sense.

    Thanks.

    Trevor
    #270422

    I am not sure what you want is currently possible with our plugin, but I have referred your question to the plugin developer, Ross, for his input.

    Anonymous
    #270467

    Thanks – appreciate the support.

    Anonymous
    #270482

    I’ve managed to sort this and hopefully it will help someone who comes across this.

    In order to be able to use the sf_ajax_results_url (or any of the url filters) it would appear that there is a check in the code to check if the search form has a ‘Results URL’ set. If it doesn’t then it doesn’t bother to kick in the URL filters. Purely because this filter is to ‘Modify’ URLs (as you say in the docs – apologies I missed this), however I wanted to set the URL completely with ‘get_the_permalink()’.

    So….make sure you set a ‘Results URL’ in your searchform in order for your filter to be able to modify/override it.

    Great plugin – works perfectly with Oxygen btw 🙂

    Trevor
    #270492

    Thanks for letting me know and sharing. I will close this thread for now.

Viewing 5 posts – 1 through 5 (of 5 total)

Search & Filter Support
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

We also use cookies to store items in your cart as well as allowing your to login on the site.

You can adjust all of your cookie settings by navigating the tabs on the left hand side.

By continuing to use this site, you also agree to our Privacy Policy.