How to add a body class based on a custom taxonomy term

What is the job of $section_name? Also you must get an return; you if statement kill the default return. It is important, if your if statement fails. maybe this works, but not tested, write from scratch. add_filter( ‘body_class’, ‘section_id_class’ ); // add classes to body based on custom taxonomy (‘sections’) // examples: section-about-us, section-start, section-nyc … Read more

How to create drop down for child categories of current taxonomy being viewed?

Ok well without any help from here……. I was able to figure out how to change the option and select values of wp_dropdown_categories to display the child terms of the current taxonomy being viewed- First I placed this code into my functions file, which creates a walker class – class SH_Walker_TaxonomyDropdown extends Walker_CategoryDropdown{ function start_el(&$output, … Read more

Last posts from custom taxonomy

First you really shouldn’t use query_posts for that use get_posts or WP_Query and second tax_query accept an array of arrays from the codex: tax_query takes an array of tax query arguments arrays (it takes an array of arrays) so: $terms=get_terms(‘tax_name’); $request=array(); foreach((array)$terms as $t) $request[]=$t->slug; $tax_q = new WP_Query( array( ‘post_type’ => ‘post’, ‘posts_per_page’ => … Read more

Check whether a custom taxonomy term has published posts?

function get_issues() { $output = array(); $hlterms = get_terms(‘issue’, array(‘orderby’ => ‘id’, ‘order’ => ‘DESC’,’hide_empty’ => false)); foreach($hlterms as $term){ array_push($output, $term->term_id); } return $output; } This would return you term id as per the recent and then in your second function start iterating to get the posts for latest issue. function get_posts_for_current_issue() { $total_issues … Read more