WordPress – Creating multiple versions of the same single-customtype.php depending on selected taxonomy categories

Okay, the following code should do the trick for you: function get_clients_correct_template($single_template) { global $post; if ( ‘clients’ == $post->post_type ) { $_template = false; // Get all the terms for this post $categories = wp_get_post_terms( $post->ID, ‘clients_categories’ ); if ( $categories && ! is_wp_error( $categories ) ) { global $wp; // I guessed that … Read more

Display child taxonomy until the last child

Got some ideas for your requirement. Check below code… $parent=get_queried_object()->term_id; $child = get_categories(‘child_of=”.$parent. “&hide_empty=0&echo=0&taxonomy=custom_taxonomy’); if(count($child)>0){ $i=0; foreach ( $child as $row ) { $i++; echo ‘<li><a href=”‘.get_term_link($row,$row->taxonomy).'”>’.$row->name.'</a></li>’; if(count($child)==$i){ $args=array( ‘post_type’ => ‘custom_post’,’order’ => ‘DESC’, ‘posts_per_page’=>1,’tax_query’ => array( array(‘taxonomy’ => ‘custom_taxonomy’,’terms’ =>$row->term_id, ‘field’ => ‘id’ )) ); $second_query = new WP_Query( $args ); if ($second_query->have_posts()) : … Read more

WordPress custom taxonomy URL rewrite on spelling errors

It also doesn’t matter which URL part is changed, except the last one. So this still shows the content of the original page. Yes, because your taxonomy’s rewrite is hierarchical with the permalink structure /treatment/<term slug> (e.g. /treatment/psychosomatic) or /treatment/<term slug>/<term slug>/… (if the term is a child term, e.g. /treatment/psychosomatic/psychosomatic-dysfunction), so as long as … Read more

Custom Comment Types

First of all, please don’t confuse terms. Custom Post Types is a mis-named feature that should really be Custom Content Types. They’re pieces of content that aren’t posts or pages, but live in the same kind of database. Like posts and pages, they can have tags, categories, comments, and other custom meta and taxonomies applied. … Read more