Sorting Tags by Slug Value

You can set orderby slug like : $tags = get_tags( ‘order=ASC&orderby=slug’ ); $html=”<div class=”post_tags”>”; foreach ( $tags as $tag ) { $tag_link = get_tag_link( $tag->term_id ); $html .= “<a href=”https://wordpress.stackexchange.com/questions/340357/{$tag_link}” title=”{$tag->name} Tag” class=”{$tag->slug}”>”; $html .= “{$tag->name}</a>”; } $html .= ‘</div>’; echo $html;

Custom template won’t load for a custom post type (custom permalinks used)

The problem in your code is the lack of proper rules. You add ‘rewrite’ => ‘CPT/%states%’ in register_post_type() arguments. This causes that the rules generated for pathologists post type begins with pathologists/%states%/ and the address pathologists/alabama/ (pathologists/{term}/) will not be matched. More importantly, all posts from the custom category are displayed regardless of the type, … Read more

How to check if do_shortcode will be execute directly in a template php file

I found a solution. First of all, the best way seems to not use do_shortcode direclty in the php. You can know more here. So… taxonomy-mytaxonomy.php <?php defined( ‘ABSPATH’ ) || exit; get_header( ); ?> <!– Content –> <div id=”content” class=”content” role=”main”> <?php the_archive_description( ‘<div class=”taxonomy-description”>’, ‘</div>’ ); if ( have_posts() ) { $queried_object = … Read more

Query all posts of a custom taxonomy term

I believe your issue is with understanding the nature of posts’ hierarchy vs pages’ hierarchy. A page is a type of “post”. It can have hierarchical structure. Posts, by default, do not have hierarchy. So, you would not be able to get post-parents without their children, because the system does not recognize a hierarchy. This … Read more

get_terms adds slaces to the resualt

What you’d need to do is double-escape, so change echo ‘\” . $term->name . ‘\’, ‘; to echo ‘\\\” . $term->name . ‘\\\’, ‘; …but, you’d be much better off just using different encapsulators: <select class=”w-100″ name=”mf_term”> <option value=” <?php $terms = get_terms( ‘call-type’ ); if ( ! empty( $terms ) && ! is_wp_error( $terms … Read more

How can marge these loop code?

Here’s an example how you could use your first code in the second one. In my code I also took the liberty to suggest one way of making your code more clear and easier to read by splitting the code into separate functions. // add the following helper functions to functions.php function travel_trip_type_image_url( int $term_id … Read more