• Resolved sm2dev

    (@kelg7)


    Hi,

    I see your plugin is compatible with FacetWP, however I am having an issue with the results page url. When using the FiboSearch field, I would like to have the results page be the same page where the FacetWP facets are used in order to allow the user to further filter down the results if needed.

    When searching for “keyword”, currently FiboSearch results redirect to /?s=keyword&post_type=product&dgwt_wcas=1

    The ideal results page would be /shop/?_search_wc_product=keyword

    If it is not possible to strip the post_type and dgwt_wcas parameters than I would like the results page to be /shop/?_search_wc_product=keyword&post_type=product&dgwt_wcas=1

    Is this possible within the pro plugin settings or with a hook/filter?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Support Kris

    (@c0nst)

    Hi @kelg7!

    Try this code snippet:

    // Redirect FiboSearch search to shop page
    add_action( 'template_redirect', function () {
    	if ( is_search() && isset( $_GET['dgwt_wcas'] ) && isset( $_GET['post_type'] ) && sanitize_text_field( $_GET['post_type'] ) === 'product' ) {
    		$dgwt_wcas = sanitize_text_field( $_GET['dgwt_wcas'] );
    		$post_type = 'product';
    
    		$redirect_url = home_url( '/shop/' );
    
    		$redirect_url .= '?s=' . urlencode( get_query_var( 's' ) );
    		$redirect_url .= '&dgwt_wcas=' . urlencode( $dgwt_wcas );
    		$redirect_url .= '&post_type=' . urlencode( $post_type );
    
    		if ( $redirect_url !== home_url( $_SERVER['REQUEST_URI'] ) ) {
    			wp_redirect( $redirect_url );
    			exit;
    		}
    	}
    } );

    You have two ways to add this code to your theme:

    1. Open the functions.php in your child theme and add the code at the end.
    2.  or install the Code Snippets plugin and apply this code as a snippet.

    Regards,
    Kris

    Thread Starter sm2dev

    (@kelg7)

    Hi @c0nst,

    Thanks for the reply and apologies for the delayed response; I have been out of town. I tried your suggested code snippet and that appears to work identically to how the plugin returns results out of the box except that /shop/ is now part of the permalink structure. That is a positive.

    However, the issue I am continuing to have is that the FacetWP filters are unusable after using the FiboSearch field because of the permalink structure that is returned after a search. Not all FacetWP filters are available because of the search query string being returned by FiboSearch. See below for screenshot of results.

    FacetWP does offer solutions for how to redirect a search box to the FacetWP results page. However, I have been unsuccessful in trying to adapt these suggestions to work with FiboSearch.

    Any insight you could provide to help resolve the compatibility between these two plugins would be extremely helpful.

    Thread Starter sm2dev

    (@kelg7)

    Hi @c0nst,

    Following up to see if you could offer another recommendation based on my previous note.

    Thanks!

    Plugin Support Kris

    (@c0nst)

    Hi @kelg7!

    I’m sorry for the late reply.

    Here’s what I found on the FacetWP single facet settings: https://prnt.sc/lxD7lUGWn0oF.
    There is an option called “Show ghosts” and “Preserve ghost order”. Please enable it and check if non-visible filters will be available.

    Regards,
    Kri

    Thread Starter sm2dev

    (@kelg7)

    HI @c0nst,

    Thanks for the suggestion but I already have those two settings (“show ghosts” and “preserve ghost order”) enabled and the non-visible filters are not available.

    As previously mentioned, the issue is because of the permalink structure that is returned after the Fibosearch search field is used. All FacetWP filters are available only when the permalink search query includes their plugin parameters.

    Permalink when using FacetWP checkboxes: https://rmdalrymplestg.wpenginepowered.com/shop/?_product_categories=1-inch

    Permalink when using Fibosearch search field: https://rmdalrymplestg.wpenginepowered.com/?s=500&post_type=product&dgwt_wcas=1

    You can see the pages are completely different. FacetWP needs /shop/?_search_wc_product= in the query string in order to work.

    Please advise.

    Thread Starter sm2dev

    (@kelg7)

    Hi @c0nst,

    Quick followup on my previous message… I reached out to FacetWP support and they mentioned, “You need to find a way to change the search box’s name/action as described in the tutorial https://facetwp.com/redirect-a-search-box-to-a-facetwp-results-page/. If you are using the FiboSearch searchbox, you need to find out if Fibo has a hook to do that.”

    Do you have a hook to change the name/action for your search field?

    Thread Starter sm2dev

    (@kelg7)

    I am writing to let you know I have been in communication with FacetWP and they were very responsive and helpful in guiding me to find a solution for this.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Redirect search action to FacetWP results page’ is closed to new replies.