base directories / URL

You can manually create pages named category and app in admin under the Pages menu, and use a custom page template for each to list out taxonomy terms or whatever you need. EDIT – 301 redirect a request that matches the pagename rewrite to another page: function wpa_parse_query( $query ){ if( isset( $query->query_vars[‘pagename’] ) && … Read more

Unable to delete a Category and Tag that share same slug

The problem is WordPress database schema for taxonomies. In database, two terms in 2 different taxonomies with same slug share the same row on terms table. They are differentiate with 2 rows on the terms_taxonomy table. So if you want to delete only the category, you have to perform a custom sql on WordPress database. … Read more

Custom post type with specific category structure

I think you’ve arrived at the structure that WP doesn’t quite support. Let’s start with following premises: Taxonomies exist for grouping posts. Hierarchical taxonomies can have multiple level of grouping (with larger groups encompassing smaller groups). But what you had drafted is something else — taxonomy grouping another taxonomy. Simply put that’s not in the … Read more

Get and loop posts with all taxonomy terms

Your best option will be to get an array of term ids by using get_terms which belongs to the authors taxonomy and then using that as your array of terms in your tax_query The following requires PHP5.4+ $term_ids = get_terms( ‘authors’, [‘fields’ => ‘ids’] ); // Only get term ids $args = [ ‘tax_query’ => … Read more

Remove Taxonomy Slug when No Taxonomy is Assigned to Custom Post Type?

With helpful tips from Milo, I was able to remove the taxonomy slug when no taxonomy is assigned to the custom post type by adding the following code to the updated functions above: add_filter( ‘request’, ‘project_request_filter’ ); function project_request_filter( $request ){ if( array_key_exists( ‘project’ , $request ) && ! get_term_by( ‘slug’, $request[‘project’], ‘project’ ) ){ … Read more

Taxonomy , subtaxonomy,child taxonomy of a product woocommerce

Based on this answer, here is my function to get all your terms in an array : function get_term_ancestors($post_id, $taxonomy){ // Declare the array where we are going to store the terms $ancestors = array(); // start from the current term $parent = array_shift(get_the_terms($post_id,$taxonomy)); // climb up the hierarchy until we reach a term with … Read more

Is there a filter hook that I can use to change how taxonomy term names are displayed?

The dynamic filter “term_{$field}” is probably what you’re looking for, where the field is “name.” One approach is to have an array of names and their pseudonyms, then do a check-and-return on them so they’ll display the replacement. add_filter( ‘term_name’, function( $value ) { $terms = [ ‘old’ => ‘new’, ]; // basic example check, … Read more