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

How to handle “the_terms” inside loop

To answer your first question What is the difference between those functions get_terms() returns an array of terms objects that belongs to a specific taxonomy get_the_terms() returns an array of terms belonging to a post the_terms() displays an HTML formatting string of term names belonging to a post Because you need your terms not hyperlinked … Read more

How to get Custom Taxonomy ID from the post ID

You can use wp_get_post_terms() which will return all the terms attached to the post, if any. Then, the first term of the array will be able to tell you which taxonomy it belongs to: global $post; $terms = wp_get_post_terms( $post->ID, array( ‘regions’, ‘sections’ ) ); if( ! empty( $terms ) && ! is_wp_error( $terms ) … Read more