get_term_by “name” not working with & in name

The characters <, >, &, ” and ‘ (less than, greater than, ampersand, double quote and single quote) are enconded in term names. & becomes &amp;. This is done by passing the term object to sanitize_term() function which applies several filters. By default WordPress applies theses filters: sanitize_text_field(), wp_filter_kses() and _wp_specialchars() (see wp-includes/default-filters.php), this last … Read more

how to filter each tag item?

On the top of my head there are two easy ways to go about this problem, first is to use the get_the_tags() function to manually loop the tags to easily insert the hashtags. $tags = get_the_tags(); if ( $tags ) { foreach ( $tags as $tag ) { ?> <a href=”https://wordpress.stackexchange.com/questions/225250/<?php echo get_tag_link( $tag->id ); … Read more

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