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

How to redirect custom post type archive to first term of associated taxonomy?

If you know you’re loading the right template, redirect to your first term of the specified taxonomy: function wpse_135306_redirect() { $cpt=”countries”; if (is_post_type_archive($cpt)) { $tax = ‘cities’; $args = array( ‘orderby’ => ‘id’, // or ‘name’ or whatever ); $cities = get_terms($tax, $args); if (count($cities)) { wp_redirect(get_term_link(reset($cities), $tax)); exit(); } } } // function wpse_135306_redirect … Read more

How do I add customize_register action AFTER adding a custom taxonomy

AFAIK it shouldn’t be a problem to get taxonomy data at the customizer_register hook state. So that problem might have different reasons, but they aren’t apparent from your question. Besides I’m not sure what you are trying to achieve, so you might want to fill the information gaps according to @Rarst’s questions. Aside from that … Read more

get_terms custom order

This can be easily done with your own custom function. What you want to do here is, get your object from get_terms() which will hold your term objects, check if your unique key is set as a parameter and then according to that, remove that key/pair and add it to the back Now, lets put … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)