Using wp_tag_cloud with only current post tag with special class

I was able to achieve this by following code: $allterms = get_terms( $taxonomy ); $pterms = get_the_terms( $post->ID, $taxonomy); $tag_list = implode(‘,’, wp_list_pluck($pterms, ‘term_id’) ); $t = explode(‘,’, $tag_list); echo ‘<div class=”tag-cloud”>’; foreach ($allterms as $term) { if (in_array($term->term_id, $t)) { echo ‘<span class=”stag active”>’.$term->name.'</span>’; } else { echo ‘<span class=”stag inactive”>’.$term->name.'</span>’; } } echo … Read more

Heirarchical URLs with CPT and custom taxonomy

In both your rewrite arguments, add ‘with_front’ => false, then for your taxonomy change ‘slug’ => ‘topics’ to ‘slug’ => ‘knowledgebase’. Finally, switch the order of your registration – so that register_taxonomy is called first. This will place the taxonomy rewrite rules above the post type rules (otherwise the latter will catch the former, since … Read more

Best Method to Switch Between Terms (Custom Taxonomy)

If I am reading your code and description correctly, you can simplify that to: $taxonomy = ‘delivery_option’; $do = get_the_terms($post->ID,$taxonomy); if (!empty($do) && !is_wp_error($do)) { $do = array_shift($do); // assuming a single value as per the description. $term = str_replace(‘-delivery’,”,$do->slug); get_template_part(‘includes/sidebar-part’,$term); } else { echo ‘<p>No custom include!</p>’; } Note, I used WordPress’s get_template_part() instead … Read more

Get posts in same category not working

This should work for a custom taxonomy. <?php function get_related_posts() { global $post; $taxonomy = ‘your_custom_taxonomy’; $terms = wp_get_post_terms( $post->ID, $taxonomy ); if($terms) { $term_arr=””; foreach( $terms as $term ) { $term_arr .= $term->slug . ‘,’; // create array of term slugs } $args = array( ‘showposts’ => 5, // you can change this to … Read more