Support » Plugin: Pods - Custom Content Types and Fields » Custom Post Type in Multiple Taxonomies

  • Resolved fireuponline

    (@fireuponline)


    Greetings! I’m having an issue when a custom post type (in this case, a ‘Business’) is associated with multiple taxonomies (in this case, a ‘Category’ or type of business.

    For example, let’s say La Casita Mexican Restaurant is in two categories, “Restaurants” and “Mexican Restaurants”.

    Both those categories are custom taxonomies I created within the Pods plugin.

    When I try to create a list of available categories (I’ll include my code below), what appears is “Restaurants” and “Mexican Restaurants and Restaurants”, but not “Mexican Restaurants”.

    So basically I get the one category alone, and then a strange combination category, but not another single version of the other category. I’m wanting “Mexican Restaurants” as well as “Restaurants”.

    Here’s the code I use to pull in available categories:

    //Set the parameters of the query
    $cat_params = array(
    ‘orderby’ => ‘business_type.name’,
    ‘order’ => ‘ASC’,
    ‘limit’ => 150000,
    ‘where’ => “business_state.meta_value = ‘$chosen_ST'”
    );

    $categories = pods( ‘businesses’, $cat_params );

    //dump results into arrays
    while ( $categories->fetch() ) {

    $cat_ids[] = $categories->display( ‘business_type.term_id’ );
    $cat_names[] = $categories->display( ‘business_type.name’ );
    $cat_slugs[] = $categories->display( ‘business_type.slug’ );
    $cat_parents[] = $categories->display( ‘business_type.parent’ );

    }

    How can I adjust my query to not skip the other category in it’s singular (for lack of a better term) listing?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Jory Hogeveen

    (@keraweb)

    Hello @fireuponline

    It seems to me that your $categories variable would be filled with businesses, not their categories.
    How are you relating these categories to the businesses.

    Cheers, Jory

    Thread Starter fireuponline

    (@fireuponline)

    Well, the $categories variable is being correctly populated by the business’s category because of the ‘business_type’ meta info. The Pods taxonomy is defined as conceptually as “Business Type” (where the slug for this is ‘business-type’). ID, name, slug, and category parent (if there is one).

    Plugin Author Jim True

    (@jimtrue)

    Are you doing a relationship to the Taxonomies? That’s never recommended

    If you’re associating your taxonomies properly, you should just be able to use get_the_term_list https://developer.wordpress.org/reference/functions/get_terms/

    Or similar functions

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom Post Type in Multiple Taxonomies’ is closed to new replies.