Sorting Posts Via Custom Taxonomy Values Using Checkboxes?

Wrap the whole thing within a form and add a submit button in it: <form method=”POST” action=””> <ul class=”filter-sub-dropdown”> … </form> Use term IDs as checkbox values instead of slugs (you’ll save a little server resources): $discipline->slug; > $discipline->term_id Then, in your functions.php file check if that form has been submitted, and change WP’s query … Read more

Custom Taxonomy tree view not showing correctly in backend

Found a solution. It is a WordPress builtin functionality, not a bug. Could be prevented with the ‘wp_terms_checklist_args’ filter. Below an example for use with Custom Post Type ‘product’ and Custom Taxonomy ‘product_category’: add_filter( ‘wp_terms_checklist_args’, ‘checked_not_ontop’, 1, 2 ); function checked_not_ontop( $args, $post_id ) { if ( ‘product’ == get_post_type( $post_id ) && $args[‘taxonomy’] == … Read more

Echo custom taxonomy term name

I managed to solve this and I will post the answer: <?php $args = array(‘number’ => ‘1’,); $terms = get_terms(‘recipes’, $args ); foreach( $terms as $term ){ echo ‘<div class=”title”>’ . $term->name . ‘recipe</div>’; }

List only first-level children of specific custom taxonomy term

First of all you need the term id of hydro term, you can retrive it using get_term_by $hydro = get_term_by(‘slug’, ‘hydro’, ‘product_cat’); After that, you can use the term id as ‘parent’ argument for get_terms $hydro_children = get_terms( ‘product_cat’, array( ‘parent’ => $hydro->term_id ) ); Now you can display a list of this children: if … Read more

Automatically assign taxonomy term if custom meta value exists

You should hook onto the save_post action. add_action( ‘save_post’, ‘add_video_taxonomy’ ); function add_video_taxonomy( $post_id ) { // you should check if the current user can do this, probably against publish_posts // you should also have a nonce check here as well if( get_post_meta( $post_id, ‘video_url’, true ) ) { wp_set_post_terms( $post_id, ‘video’, ‘your_custom_taxonomy_name’, true ); … Read more

Get multiple term objects by ids

I wonder if you mean something like this modified Codex example: // Fetch: $terms = get_terms( ‘category’, array( ‘include’ => array( 1, 2, 3 ), ) ); // Output: if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) { $li = ”; foreach ( $terms as $term ) { $li .= sprintf( … Read more

What are terms and taxonomy, how they related to post and how these three are stored in database?

What are the terms and taxonomy in wordpress? From WordPress.org’s Taxonomy Codex… In WordPress, a “taxonomy” is a grouping mechanism for some posts (or links or custom post types)… The names for the different groupings in a taxonomy are called terms. Using groupings of animals as an example, we might call one group “birds”, and … Read more