wp_get_post_terms Order by not working

Your title is wp_get_post_terms Order by not working but if you use a custom post type you need to use wp_get_object_terms() I’m not sure what your aim is, but here is a code example you can try: $my_post_type=”post”; // edit this $my_taxonomy=”category”; // edit this $my_query = new WP_Query(array(‘post_type’ => $my_post_type,’posts_per_page’=>10)); if ($my_query->have_posts()) : while … Read more

Display all posts that use a custom taxonomy

I think your problem is here: ‘terms’ => array($clients_terms->slug) You define $clients_terms like so: $clients_terms = get_terms(‘clients’); …which will return an array of objects. But you try to access it as an object in your query args. That should be producing some kind of PHP notice? (Trying to get property of non-object, or something?) Try … Read more

Query to get term id using post id?

It is not good practice to use query when you have already builtin functions but for your need. Try this solution: global $wpdb; $meta = $wpdb->get_row( “SELECT * FROM `wp_postmeta` WHERE `meta_id` = $id” ); //will return same object like returned by get_metadata_by_mid() function print_r($meta); Debugging Technique: As you mentioned, get_metadata_by_mid() isn’t working on live … Read more

Targeting custom post type

You can make use of get_post_type( $post ) to check whether a post belongs to a certain post type Inside your loop, you can do the following check while ($my_query->have_posts()) : $my_query->the_post(); if ( ‘activists’ == get_post_type() ) { /* Custom code for ‘activists’ post type. */ } else { /* Custom code for the … Read more