• This is mainly a note for the developer but thought I’d post it here in case it helps anyone else.

    I’m running version 1.2.5 with WP 3.9 in a custom theme. There are four custom post types, with two global custom taxonomies. Each post type archive has the the filter shortcode in it, allowing users to filter on both custom taxonomies, but with no search box.

    The issue is: if a user selects a combination of terms that produces no results, the natural instinct (for me anyway) is to choose the “select all” option in each of the taxonomy dropdowns to reset the search. Because the post type url parameter outputs ?post_types= this takes the user to the index.php template (with no results) rather than the post type archive template, so they’re unable to just filter again.

    This might be by design, but it caused me some problems! So I’ve made an amendment to search-filter.php (naughty I know) so that if there’s only one post type being filtered it outputs the singular url parameter.

    https://pastebin.com/7w3sbV5L

    Hope this helps!

    https://www.ads-software.com/plugins/search-filter/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author DesignsAndCode

    (@designsandcode)

    Hey Martin

    Thanks for your code – it is indeed by design default, and the code you supplied (without checking) fits your specific use case – which some other users will also be experiencing – so thanks for that.

    I did not want to make the plugin do too much in this regard as I see it as more of a theme issue than plugin – you can set your theme up to load different templates depending on things like the url and I didn’t want to break any sites already using the plugin.

    Thanks for this anyway – I will have a good look through and see if its something I could include in the plugin ??

    Best
    Ross

    Hi Martin,

    nice idea to solve.

    I just came over the same problem, but think to solve it with page redirect on the wrong/not working url-parameter.

    best
    Jarno

    Hi,

    this sounds similar to a problem i’m having. I have a custom post type “book” and a custom taxonomy “book_tags” so that user can filter books according to a book tag. Everything works fine as long as they don’t try to submit an empty search (they don’t enter anything in the search field, and they don’t select a book tag). Then my url looks like this “www.mywebsite.com?post_types=book”, and it displays posts, instead of books. I even tried using “empty_search_url” parameter to redirect the page to my library, so that they can see all books, but it doesn’t work with custom post types. It works only if i remove post_types=”book”. Can you help with redirecting the user to a specific page or tell me if i’m doing something wrong? my shortcode looks like this

    [searchandfilter fields=”search,book_tags” all_items_labels=”,All Books” post_types=”book” empty_search_url=”my/library/webpage/here” show_count=”1″]

    Thanks

    P.S.

    Can i use show_count=”1″ here to display number of books that belong to a certain taxonomy term?

    hi DSkyline,

    i posted my redirect solution on pastebin.
    https://pastebin.com/AvnJ7Ccn

    hope this helps
    j

    Hi jarnoschi,

    tnx for your “hacky” solution, it works. I just had to put the code in my home.php file instead of index.php. I also used some input sanitization, just in case ?? . Thanks for the help.

    you are welcome.
    thanks for pointing out the sanitization issue.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘post_types URL parameter issue’ is closed to new replies.