Get Current Custom Taxonomy ID by Post ID

(Probably better to use get_the_terms). $terms = wp_get_object_terms( $pid, ‘custom_category’, array(‘fields’=>’ids’)); Get an array of term ids (will always been array, even if it is an array of one): $ids = wp_list_pluck( $terms, ‘term_id’ ); If you just want one id… then ‘pop’ out the last id: $id = array_pop($ids); See also PHP docs on … Read more

get_term_children doesn’t return an array of children terms

At first, try passing the Taxonomy as a string: $children = get_term_children($term->term_id, ‘locations’); The function get_category_children produces a string as return, so you can just echo it. the function get_term_children, however, returns an array. To see the contents of the array, try print_r( $children ); instead of echo. The last thing to keep in mind … Read more

Permalinks for custom taxonomy stopped to work

Sometimes a plugin changes WordPress’ internal rewrite rules during an update, an installation or deactivation. If the plugin’s update happens to run after your taxonomy registration it may just wipe out the custom rules for the taxonomy. To inspect the currently active rewrite rules use the plugin Monkeyman Rewrite Analyzer. See this answer for details. … Read more

$wpdb query a post type within a specific taxonomy term while ordering posts by custom meta value?

You have a typo in orderby, and meta_value_num is only used as an orderby value, try this: $args = array( ‘post_type’ => ‘event’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘locations’, ‘field’ => ‘id’, ‘terms’ => $location // location term id ) ), ‘meta_key’ => ‘event_date’, // this meta field stores event date in yymmdd format … Read more

How do I Use Multiple Loops with WP_Query?

As Toscho mentionned above, you didn’t close your if and while. When in doubt, indent your codes to avoid confusion. $my_query = new WP_Query( $args ); if ($my_query->have_posts()) : while($my_query->have_posts()) : $my_query->the_post(); endwhile; endif; wp_reset_postdata(); /* The 2nd Query (without global var) */ $query2 = new WP_Query( $args2 ); // The 2nd Loop if ($query2->have_posts()) … Read more

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