What is the term shortlink structure?

Well if you are referring to what are the query string keys are, it will depend on the taxonomy you are working with, for categories: you are looking for ?cat=cat_id tags: you are looking for ?tag=tag_slug custom taxonomy: it depends on the slug of the tax but it will look like ?taxonomy_slug=item_slug Check the definition … Read more

Change term name only on front

You can detect if you are in the frontend using the function is_admin(), like so: add_filter(‘get_term’, ‘filter_term_name’, 10, 2); function filter_term_name($term, $taxonomy) { // return the term untuched if you are in the admin if( is_admin() ) { return $term; } if ($taxonomy == ‘my-taxonomy’) { // numeric value of term in another taxonomy $meta_value … Read more

Display hierarchical subterms of custom taxonomy based on depth

I love a good challenge! The function here: function get_post_categories_sorted ( $post_id ){ $terms = wp_get_post_terms( $post_id, ‘category’ ); $sorted_terms = []; foreach( $terms as $term ){ $depth = count( get_ancestors( $term->term_id, ‘category’ ) ); if( ! array_key_exists( $depth, $sorted_terms ) ){ $sorted_terms[$depth] = []; } $sorted_terms[$depth][] = $term; } return $sorted_terms; } will give … Read more

Custom Taxonomy Archive BUG

as mentioned by @mmm you loop over the terms and in each term you loop over each project – however I think this is what you wanted to do: $terms = get_terms( array( ‘taxonomy’ => ‘residential_project_types’, ‘orderby’ => ‘count’, ‘hide_empty’ => true ) ); foreach( $terms as $term ) : ?> <a class=”property-thumb-link” href=”https://wordpress.stackexchange.com/questions/264897/<?php echo … Read more

How do I get a list of all categories that a given user has written blog posts for?

As, much as I know about WordPress we have to ways to achieve this. First: You have to retrieve all posts written by an author an then you can fetch categories assigned to those posts. Store them in an array uniquely. $args = array(‘author’ => $author->ID, ‘posts_per_page’ => -1, ‘fields’ => ‘ids’); $authorArticles = get_posts($args); … Read more

Get child product categories from parent product category in WooCommerce

Edited (1) You will need to use ‘child_of’ from WP_Term_Query available arguments, that will let you to get all child terms for the current product category parent term: // Only on product category archive pages if( is_product_category() ) { $main_term = get_queried_object(); $args_query = array( ‘taxonomy’ => ‘product_cat’, ‘hide_empty’ => false, ‘child_of’ => $main_term->parent ); … Read more

get_the_terms – only top level

Just have a quick test and seems both methods working well. // @Rup’s method $terms = get_the_terms(get_the_ID(), ‘my_taxonomy’); if (!is_wp_error($terms) && !empty($terms)) { foreach ($terms as $term) { // skip if parent > 0 if( $term->parent ) continue; $name = $term->name; $link = add_query_arg(‘fwp_typ’, FWP()->helper->safe_value($term->slug), ‘https://www.freuciv.com/’); echo “<a href=”https://wordpress.stackexchange.com/questions/366690/$link”>$name</a><br />”; } } or $terms = … Read more