How to orderby Taxonomy Term in a WP Query

You can’t order by taxonomy terms, the very concept breaks down when you try to handle posts that have multiple terms in a taxonomy. You may know that only 1 term will ever be selected but WP_Query isn’t built that way. Instead, keep your taxonomy so that you retain all the performance/theming/Admin UI benefits, but … Read more

How to display a term of taxonomy

I found the solution thanks to answer this question: Specify number of posts in my ‘tax_query’ I wanted to show the posts for ‘futbol’ within the ‘tipo_deporte’ taxonomy: <?php $args = array( ‘posts_per_page’ => 2, ‘tax_query’ => array( array( ‘taxonomy’ => ‘tipo_deporte’, ‘field’ => ‘slug’, ‘terms’ => array(‘futbol’), ) ) ); $query = new WP_Query( … Read more

Append taxonomy url

You have at least 3 ways of accomplishing this. Option 1 The easiest is to change your permalink structure to “Post Name”, and then create your landing pages with the slugs you want. So, your slug for york would be “trainers-in-york”. Option 2 If you absolutely must modify the url, you can use add_rewrite_rule to … Read more

What is the ‘selected’ parameter in wp_dropdown_categories() for?

The selected parameter just defines which option is selected when the select field is rendered. it’s an optional parameter that defaults to the current category or 0 $defaults[‘selected’] = ( is_category() ) ? get_query_var( ‘cat’ ) : 0; (https://developer.wordpress.org/reference/functions/wp_dropdown_categories/) This function is for rendering a category drop down, but you can override it to work … Read more

Show Taxonomy Child Terms (name and image) on Parent Term Page

You can try this. $parent_terms = get_terms( array( ‘taxonomy’ => ‘post_tag’, ‘hide_empty’ => false, ) ); foreach ( $parent_terms as $terms) { $term = get_terms(array( ‘taxonomy’ => ‘post_tag’, ‘hide_empty’ => false, ‘parent’ => $terms->term_id ) ); foreach ($term as $term_child){ $string .= ‘<li><a href=”‘ . get_term_link( $term_child->term_id ) . ‘”>’ . $term_child->name . ‘</a></li>’; } … Read more