rmorse / search-filter

Search & Filter is a simple search and filtering plugin for WordPress
GNU General Public License v2.0
93 stars 41 forks source link

Feature suggestion: Option to not switch search results URL to permalink #67

Open inspiredearth opened 3 years ago

inspiredearth commented 3 years ago

Hi there,

I'd like to suggest adding an option to disable the behaviour of converting the search URL to a permalink. Referring to this:

In addition to this, if permalinks are enabled, when you submit a search, Search & Filter will try to remove `category_name` from the url and instead rewrites the URL to first obey a clean category URL with the rest of the query string following.

This url:
www.yourdomain.com/?s=searchterm&category_name=uncategorized&tag=shoes&customtaxonomy=customvalue

Becomes:
www.yourdomain.com/category/uncategorized/?s=searchterm&tag=shoes&customtaxonomy=customvalue

I have a usage scenario where I would rather it didn't remove the 'category_name'.

In the mean time, is there an easy way I could remove this feature, by editing some code somewhere?

Am I correct in thinking it may be as simple as commenting out these lines in search-filter.php

if(get_option('permalink_structure'))
                    {
                        //$catrel = trim(str_replace(home_url(), "", get_category_link()), "/").$categories."/"; //get full category link, remvoe the home url to get relative, trim traling slashed, the append slash at the end
                        $category_base = (get_option( 'category_base' )=="") ? "category" : get_option( 'category_base' );
                        $category_path = $category_base."/".$categories."/";
                        $this->urlparams .= $category_path;
                    }
                    else
                    {

And the two other permalink related code sections not found in the Github file, but in the current release file.