Get terms within a custom taxonomy

In wordpress a parent for a term is always referred to the same taxonomy. So as you already understand what you need is create a texonomy in which parent term rapresents a ‘School’ and a child term rapresents a ‘Group.’ Maybe a third-level-term rapresents a ‘Sub-Group’ or something else. Doing so and using the argument … Read more

Get the ID of category page with or without any posts

Make use of get_queried_object_id() in your category page. This will return the ID of the category. This is really useful little function. It will return the the: author ID on an author archive page term ID on a taxonomy, tag and category archive pages post ID on a single post page page ID of a … Read more

Add HTML to Term Description

The only way I can see for getting this to work is running the output through html_entity_decode() and stripslashes() and saving it with esc_attr(): Saving the term: $wpdb->update( $wpdb->term_taxonomy, array( ‘description’ => esc_attr( $_POST[‘_term_desc’] ) ), array( ‘term_id’ => $term_id ) ); Showing the term on the front end: echo apply_filters( ‘the_content’, html_entity_decode( stripslashes( $term->description … Read more

wp_insert_post() does not support variable

There is no difference in PHP between a string and a variable set to a string, so the problem is elsewhere. Most likely it is with passing the slug argument as mentioned in the codex for wp_insert_term: https://codex.wordpress.org/Function_Reference/wp_insert_term : If ‘slug’ argument exists then the slug will be checked to see if it is not … Read more

Add class to first post queried

<?php $_terms = get_terms( array(‘claim-accordion-type’) ); $i = 0; foreach ($_terms as $term) : $term_slug = $term->slug; $_posts = new WP_Query( array( ‘post_type’ => ‘claims_accordion’, ‘posts_per_page’ => -1, ‘tax_query’ => array( array( ‘taxonomy’ => ‘claim-accordion-type’, ‘field’ => ‘slug’, ‘terms’ => $term_slug, ), ), )); if( $_posts->have_posts() ) : $i++; if ( $i == 1 ) … Read more

get_the_terms() not returning expected result

If you are trying to get the number of terms your post have, then you should use wp_get_post_terms(). $sizeCount = count(wp_get_post_terms($post->ID, ‘sizes’)); $colorCount = count(wp_get_post_terms($post->ID, ‘colors’)); echo $sizeCount . ‘ ‘ . $colorCount;

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