• I have an issue and I’m trying to figure out how i can possibly do this! If you have any suggestions, please let me know!
    So what I have currently is
    four cities: New York, Dublin, Cape Code and Boston
    three categories: Shops, Places, Restaurants

    All the cities and categories are currently set as “categories” . In the menu i have a menu button with a drop down for the cities and one for the categories.

    What I’m trying to figure out is a way to refine a search and narrow it down by city and category.

    The client doesnt want a “search form”

    The one way i was considering was changing the categories to tags but then it gets cumbersome for the user who has to remember to set a category and to set a tag.

    Any Suggestions?

Viewing 2 replies - 1 through 2 (of 2 total)
  • This function makes WordPress accept multiple categories in the URL by separating them with a space or ‘+’:

    function custom_category_search_logic( $query ) {
      if ( ! isset( $query->query_vars[ 'category_name' ] ) )
      return $query;
      // split cat query on a space to get IDs separated by '+' in URL
      $cats = explode( ' ', $query->query_vars[ 'category_name' ] );
      if ( count( $cats ) > 1 ) {
        unset( $query->query_vars[ 'category_name' ] );
        $query->query_vars[ 'category__and' ] = $cats;
      }
      return $query;
    }
    add_action( 'parse_request', 'custom_category_search_logic', 11 );

    Then the url to pull up ‘places’ in ‘Dublin’ would be https://www.yourwebsite.com/?category_name=dublin+places

    Thread Starter RaiderKat

    (@raiderkat)

    Thanks for replying! The question then is how would i have them do a search using the actual menu button as opposed to a search and also allowing them to add new cities or categories easily?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Help with Combining categories -refine search’ is closed to new replies.