menu for custom type and taxonomy at the same time or filter by type

I have two custom types (eg: Cooks and Restaurants) and both have a shared taxonomy (eg: specialty). I want a menu that pulls all the restaurants based on a specific specialty but there doesn’t appear to be a way to use appearance -> menu to add the specialty taxonomy so that it only links to restaurants but not to cooks. eg: a menu that basically does a search for one type with that taxonomy match but doesn’t also pull the other type with that taxonomy match

To be clear I can get the taxonomy with both by simply editing a menu, placing a check-mark in the taxonomy name in screen options and then adding the individual taxonomy terms… I just don’t see how to filter the results to be only a single type. I assume that I will need to do this with some code but wanted to be sure I wasn’t over-engineering it.

Is there a way that is built into WordPress that would allow this to be done or am I looking at writing some custom code/adding a plugin? Alternately… what keywords should I have used to find an answer to this? It seems like anything that is remotely related is dealing with using a taxonomy with the same name as a type. I also looked at the title (at a minimum) of all the advanced-taxonomy-queries tagged questions when I discovered that but none seemed to be like my issue (though many were interesting in other ways).

Sort custom post type by custom taxonomy

Im using this code to sort my custom post type by one of its custom taxonomies:

   <?php         $  valores = get_terms('valor', array('order' => 'DESC',));         foreach($  valores as $  valor) {             $  posts = get_posts(array(                     'post_type' => 'propriedade',                     'tax_query' => array(                         array(                             'taxonomy' => 'valor',                             'field' => 'slug',                             'terms' => $  valor->slug                             )                         ),                     'numberposts' => -1                 ));             foreach($  valores as $  valor) {                 print_r($  valor);             }         }     ?> 

but the list seems not to be ordered as DESC:

WP_Term Object (     [term_id] => 28     [name] => 40000     [slug] => 40000     [term_group] => 0     [term_taxonomy_id] => 28     [taxonomy] => valor     [description] =>      [parent] => 0     [count] => 1     [filter] => raw ) WP_Term Object (     [term_id] => 32     [name] => 2000000     [slug] => 2000000     [term_group] => 0     [term_taxonomy_id] => 32     [taxonomy] => valor     [description] =>      [parent] => 0     [count] => 1     [filter] => raw ) WP_Term Object (     [term_id] => 27     [name] => 2000     [slug] => 2000     [term_group] => 0     [term_taxonomy_id] => 27     [taxonomy] => valor     [description] =>      [parent] => 0     [count] => 1     [filter] => raw ) 

What I need is to make name or slug start from the lowest value to the higher value.

Disable custom taxonomy by name in function

I need delete some custom taxonomy with function. Users creates new taxonomies, but when user create any disabled taxonomy (for example named "custom_taxonomy1") so WP remove it with function (so blacklist for specific taxonomy name).

How can I delete with something like this:

If post type "custom_post_type" – do remove taxonomy with name array "custom_taxonomy1", "custom_taxonomy2"...

or with wp_remove_object_term() function

or I find this, but how achieve it:

function wpse_296972_pre_delete_term( $  term_id, $  taxonomy_name ) {     if ( $  taxonomy_name === 'organization' ) {         $  objects = get_objects_in_term( $  term_id, $  taxonomy );          // delete here .     } } add_action( 'pre_delete_term', 'wpse_296972_pre_delete_term' ); 

How to Filter custom post type by taxonomy?

here is my code trying to make it

  <div class="row"> <div class="col-lg-3 col-md-12"> <div class="card">     <div class="card-body">     <form action="<?php the_permalink() ?>" method="GET">   <?php  $  terms = get_terms([   'taxonomy' => 'topics',   'hide_empty' => false ]);  foreach ($  terms as $  term) :  ?>  <label>      <input       type="checkbox"       name="topics[]"       value="<?php echo $  term->slug; ?>"       <?php checked(         (isset($  _GET['topics']) && in_array($  term->slug, $  _GET['topics']))       ) ?>     />      <?php echo $  term->name; ?>    </label>  <?php endforeach; ?>   <button type="submit">Apply</button>  </form>      </div> </div>     </div><!--end of col1 -->     <div class="col-lg-9 col-md-12"> <div class="row"> <?php $  courses = new WP_Query(     array(         'post_type' => 'courses', // This is the name of your post type - change this as required,         'posts_per_page' => -1,         'tax_query' => array(                             array(                                 'taxonomy' => 'topics',                                 'field'    => 'slug',                                 'terms'    => $  term->slug,                                 'operator' => 'IN'                                 )         ) // This is the amount of posts per page you want to show     ) ); while ( $  courses->have_posts() ) : $  courses->the_post(); // The content you want to loop goes in here: ?> <div class="col-lg-6 col-md-12">                                 <div class="card shadow bounceIn"                                     style="margin-top: 10px; border: none; border-radius: 13px;">                                     <div class="card-header"                                         style="color: white; text-align: start; border-top-left-radius: 13px; border-top-right-radius: 13px; background-color: #EE225D;  border:none;">                                         <h6 style="padding-bottom: 0; margin-bottom: 0;"><?php the_title(); ?></h6>                                     </div>                                     <div class="card-body"                                         style="padding-top: 20px; padding-bottom: 20px; color: #2B2365;">                                         <h6 style="font-weight: 700;"><?php the_field('full_name'); ?></h6>                                         <p><?php echo wp_trim_words( get_the_content(), 30, '...' ); ?></p>                                         <a  href="<?php the_permalink(); ?>"                                             style="float:right; color: #EE225D; background-color: transparent; border-color: #EE225D;">View                                             Course</a>                                     </div>                                 </div>                             </div>  <?php endwhile; rewind_posts(); wp_reset_postdata(); ?>   </div>     </div><!--end of col2 --> </div> 

but when i refresh the page it keeps trying to load and when i remove function rewind_posts it load the page but filters not working i watched many videos trying to solve it but no success code explanation two columns one having the filters and second column having the posts

Is it possible to have dedicated page for parent/child taxonomy?

I’ve been working non-stop on this for the past few days. I have a post type, floorplan, which has a hierarchical taxonomy called County. Each County taxonomy has child taxonomies with the names of communities within each county, which I’ve been able to apply to the post permalinks by following This Guide. So my post urls are now floorplans/{parent-county}/{child-county}/{the-floorplan}

Now, I have a custom county-taxonomy.php template that displays all posts of this type that have the county taxonomy assigned. The url is floorplans/{parent-county} where parent county is the parent taxonomy. This template will also display if you navigate to the url floorplans/{child-county} where child-county is the child taxonomy.

HOWEVER, if I try to navigate to floorplans/{parent-county}/{child-county}, I get a 404.

So my basic question, is it possible to modify the permalink of the taxonomy page such that it includes both parent and child?

Possible to remove taxonomy from permalink if uncategorized?

I’m working on a client’s website who requested that the custom search functionality I’m building out provide a number of ‘pretty’ permalinks that they can use for ad campaigns.

The post types I’m working with are community, floorplan, and ready-made homes, and they want to be able to have direct links to search results by county and community.

To achieve this, I set up taxonomies that would create nicely formatted URLS such as {county}/{community}, {county}/{community}/{floorplan} {county}/{community}/{ready-made}.

This is all working fine, however it leads to some issues. For example, If you do not specify a county in your search, you will get links like uncategorized/{community} returned in the results.

Is there any way that you can remove uncategorized taxonomy from the URL, but leave the taxonomy in if it exists?

I’ve figured out how to update the URLs in the search results, however they will lead to 404s if left completely empty because they technically don’t exist if you remove the taxonomy from the url. Ideally, I would want them to just redirect to communities/{community} for example, instead of communities/uncategorized/{community}

Custom Taxonomy is Missing (Or Limiting) Items

I created a custom taxonomy; "places" using toolset

region>country>city with 12 Regions / All Countries and just a few cities; 12 parents, 260 children

Where I am using the taxonomy in a post, custom post type or the menu, only some of the items show and it is quite random. 1/2 of Europe shows up 3 from the Caribbean, etc

I used the plugin Toolset; this issue has repeated in 4 different installs. I have worked with hosting and they assure me it is a development issue. I have worked with toolset and am on Day 6 of no solution; I have tried with different themes (Hello & Astra), Using Elementor or not (no plugins other than toolset itself; there is no support over the weekend. Does anyone have any idea WHY I would be missing just some of the taxonomy?

I am not seeing any errors in debugging

Sort the result of the main Query in shop page by a custom taxonomy

In a WooCommerce site, we have products that have a custom taxonomy that are assign to a region.

When the user visits the site, we activate the browser geolocation, and we assign the user a region in a cookie.

Now we would like to show, in the shop page and in the product_cat taxonmies, in first the products that are assign to the same region of the user and then all other regions.

How could we implement this ?

So far, I taught of using pre_get_posts, and using something like :

add_action('pre_get_posts', 'order_by_region', 999999); function order_by_region($  q){  if(!is_admin() && $  q->is_main_query() && (is_shop() || is_tax('product_cat'))){   $  q->set('orderby', 'meta_value');   $  q->set('order', 'DESC');   $  q->set('value', $  _COOKIE['nameofusercookie']);   $  q->set('meta_key', 'regions');   }   return $  q; } 

But this didn’t work. I just found that in there it will filter the posts instead of ordering by regions.

I found the ‘the_posts’ hook. That contains all the products after quering but not yet looped. I think it might be better place to sort all the products with the cookie. But how do i compare the cookie and the regions taxonomy in each products ?

add_filter('the_posts', 'sort_query_by_region', 10, 2); function sort_query_by_region($  posts, $  q){  $  cookie = $  _COOKIE['selected_region'];   if(isset($  cookie) && !empty($  cookie)){   if(!is_admin() && $  q->is_main_query() && (is_shop() || is_tax('product_cat'))){    $  posts = sortByRegion($  posts);   }  }  return $  posts; }  function sortByRegion($  posts){  usort($  posts, "regionOrder");  return $  posts; }  function regionOrder($  a, $  b) {    // get the cookie    $  cookie = $  _COOKIE['slected_region'];    // Get the term region of each compared product   $  regionA = get_the_terms($  a->ID, 'regions')[0]->slug;   $  regionB = get_the_terms($  b->ID, 'regions')[0]->slug;    if($  regionA != $  cookie || $  regionB != $  cookie){    return ($  a, $  b);   } else {    return $  a < $  b;   } } 

I must that either doesn’t work.

Anyone everdone such a re-ordering and knows I to help me?

Show content/template for the /tag/ or /taxonomy/ part of the URL in WordPress


I’ve been trying to figure this problem out but can’t quite find an answer.

On my WordPress site, the URL for tags is This displays fine using the tag.php template. However, If I just go to I get a 404 error. It is the same for custom taxonomies I have. For example, I have custom taxonomy of developer so if I goto it loads content under that term using taxonomy-developer.php template. But going to returns a 404.

Is there a template I can use, or some other method to get WordPress to display a list of terms if someone goes to the /tag/ or /taxonomy/ part of the URL?


Custom Post Type / Taxonomy not displaying archive

I am trying to use the Atreas Theme:

This is the site I am working on:

All I want is an archive page for my Team Members to display them all in one spot. I tried adding: 'has_archive' => true' to the plugin php files directly “cpost-team.php” but I can’t for the life of me find the url for the archive page for Team Members. Either that or I’m missing something else. This is the direct code for this “Custom Posts” (aka Team Members) plugin:

<?php  //Define team post type add_action( 'init', 'cpo_cpost_team' ); function cpo_cpost_team() {    $  show_ui = false;    if ( defined( 'CPOTHEME_USE_TEAM' ) || cpo_get_option( 'display_team' ) ) {        $  show_ui = true;    }    $  labels = array(        'name'               => __( 'Team Members', 'cpo-companion' ),        'singular_name'      => __( 'Team Member', 'cpo-companion' ),        'add_new'            => __( 'Add Team Member', 'cpo-companion' ),        'add_new_item'       => __( 'Add New Team Member', 'cpo-companion' ),        'edit_item'          => __( 'Edit Team Member', 'cpo-companion' ),        'new_item'           => __( 'New Team Member', 'cpo-companion' ),        'view_item'          => __( 'View Team Member', 'cpo-companion' ),        'search_items'       => __( 'Search Team Members', 'cpo-companion' ),        'not_found'          => __( 'No team members found.', 'cpo-companion' ),        'not_found_in_trash' => __( 'No team members found in the trash.', 'cpo-companion' ),        'parent_item_colon'  => '',    );     $  member_slug = cpo_get_option( 'slug_team_member' );    if ( '' == $  member_slug ) {        $  member_slug = 'cpo_team';    }     $  fields = array(        'labels'              => $  labels,        'public'              => true,        'publicly_queryable'  => true,        'exclude_from_search' => true,        'show_ui'             => $  show_ui,        'query_var'           => true,        'rewrite'             => array( 'slug' => apply_filters( 'cpotheme_slug_team_member', $  member_slug ) ),        'capability_type'     => 'page',        'hierarchical'        => false,        'menu_icon'           => 'dashicons-universal-access',        'menu_position'       => null,        'supports'            => array( 'title', 'editor', 'excerpt', 'thumbnail', 'page-attributes' ),    );     register_post_type( 'cpo_team', $  fields );  }   //Define admin columns in team post type add_filter( 'manage_edit-cpo_team_columns', 'cpo_cpost_team_columns' ); if ( ! function_exists( 'cpo_cpost_team_columns' ) ) {    function cpo_cpost_team_columns( $  columns ) {        $  columns = array(            'cb'             => '<input type="checkbox" />',            'ctct-image'     => __( 'Image', 'cpo-companion' ),            'title'          => __( 'Title', 'cpo-companion' ),            'ctct-team-cats' => __( 'Groups', 'cpo-companion' ),            'date'           => __( 'Date', 'cpo-companion' ),            'author'         => __( 'Author', 'cpo-companion' ),        );        return $  columns;    } }  //Define team category taxonomy add_action( 'init', 'cpo_tax_teamcategory' ); if ( ! function_exists( 'cpo_tax_teamcategory' ) ) {    function cpo_tax_teamcategory() {        $  labels = array(            'name'               => __( 'Member Groups', 'cpo-companion' ),            'singular_name'      => __( 'Member Group', 'cpo-companion' ),            'add_new'            => __( 'New Member Group', 'cpo-companion' ),            'add_new_item'       => __( 'Add Member Group', 'cpo-companion' ),            'edit_item'          => __( 'Edit Member Group', 'cpo-companion' ),            'new_item'           => __( 'New Member Group', 'cpo-companion' ),            'view_item'          => __( 'View Member Group', 'cpo-companion' ),            'search_items'       => __( 'Search Member Groups', 'cpo-companion' ),            'not_found'          => __( 'No member groups were found.', 'cpo-companion' ),            'not_found_in_trash' => __( 'No member groups were found in the trash.', 'cpo-companion' ),            'parent_item_colon'  => '',        );         $  slug = cpo_get_option( 'slug_team_category' );        if ( '' == $  slug ) {            $  slug = 'team-group';        }        $  fields = array(            'labels'            => $  labels,            'public'            => true,            'show_ui'           => true,            'show_in_nav_menus' => true,            'show_tagcloud'     => false,            'rewrite'           => array( 'slug' => apply_filters( 'cpotheme_slug_team_category', $  slug ) ),            'hierarchical'      => true,        );         register_taxonomy( 'cpo_team_category', 'cpo_team', $  fields );    } } 

Also based on the code what should the url outcome be? I assumed it should be on:

Additionally my custom taxonomy for team members (groups) is not displaying posts that fall under the given group: enter image description here

Sorry I’m not great with php. Thank you in advance!!