Support

Account

Home Forums Front-end Issues Filter Nested Taxonomies

Helping

Filter Nested Taxonomies

  • Hi,

    I’m trying to solve the following issue:

    I’ve a custom post type ‘project’ and two custom taxonomies ‘customer’ and ‘industry’. Each ‘Project’ gets a ‘customer’ assigned whereas each ‘customer’ gets assigned to an ‘industry’. So far so good.

    Now I’m trying to list the terms for the projects with the_terms(). WordPress will list all ‘customer’ but not ‘industry’. The count of each industry in the backend also doesn’t get raised when I assign an industry to a customer. This has obviously something to do with nesting the taxonomies. The setting ‘Save Term’ in the ACF Taxonomy field also doesn’t change that behavior.

    I’m able to list all used industries:

    
    $terms = get_terms(array('taxonomy' => 'companies'));
        foreach ($terms as $term):
          print_r(get_field('industry',"{$term->taxonomy}_{$term->term_id}"));
        endforeach;
    

    But at the end I wan’t to be able to filter the projects by either customer or industry. But the industry doesn’t get assigned to the project so wordpress’ archive functionality doesn’t work.

    Is there a way to archive that? Any suggestions, something I’m missing in the settings or in my setup?

    Thanks

  • I would probably have made customers a custom post type, with projects related to customers and customers being in an industry, that would come with its own set of problems.

    saving and loading terms won’t work because in WP, terms can’t have terms.

    The way you’re doing in is that you’ll need to get the list projects, get the customer terms and then loop through them to get the values from the ACF industry taxonomy field on each customer term in order to display them.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.