How to update incorrect post count in taxonomy?

It only took 3.5-years for someone to be put into the position of @robert-andrews to chase down the post count problem. While having the same problem (and misinterpretation), I ran across your post yesterday in my search for answers. Nothing good really turned up. So, I was forced to trace the code and take the … Read more

How to order get_term_children output by alphabetic order

Per your comment (and hopefully an edit to the question) : I did it like so: foreach ( $termchildren as $child ) { $term = get_term_by( ‘id’, $child, $taxonomy_name, array( ‘orderby’ => ‘name’, ‘hide_empty’ => 0) ); Formatted: foreach ( $termchildren as $child ) { $term = get_term_by( ‘id’, $child, $taxonomy_name, array( ‘orderby’ => ‘name’, … Read more

Prevent Selected Terms Rising to the Top

This bugs me too. It is very confusing, so I thought I’d look into it. That meta box is created in “wp-admin/includes/meta-boxes.php” on line ~399. It uses wp_terms_checklist. The problem codes seems to be this (it is one in source): <?php wp_terms_checklist( $post->ID, array( ‘taxonomy’ => $taxonomy, ‘popular_cats’ => $popular_ids ) ) ?> That leaves … Read more

How do I access a single term from a post?

It’s a little bit hard to be sure, what are you asking exactly, but… Let me try to answer… So somewhere in single.php you’re getting terms for current post using this code: $terms = wp_get_post_terms($post->ID, ‘mytax’, array(“fields” => “all”)); and you want to get the ID of first term from that list? If so, you … Read more

same taxonomy for several post types: how to hide empty in a specific post type?

Thanks to this answer, I was able to see the light. Here is how to query taxonomy terms related to (woocommerce) products that are “in stock”. It uses both tax_query (to relate product to taxonomy) and meta_query (to filter out out-of-stock products). $artists = get_terms_by_post_type( array(‘artist’), array(‘product’)); if( !empty($artists) && !is_wp_error( $artists ) ){ // … Read more

Exclude Child Terms From Parent Posts

In your get_terms() call, try setting the hierarchical option to false: $children_terms = get_terms($taxonomy, array( ‘parent’ => get_term_by(‘slug’, $parent_term, $taxonomy)->term_id, ‘hierarchical’ => false )); This option normally defaults to true, which is probably why you’re getting the extra copies.

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