Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Update Meta_key of all posts that have relationship specific term WordPress


I have a query that allows me to update the meta_value of my meta_key 'post_view_count' - for all my posts:

global $wpdb;
$wpdb->query( $wpdb->prepare( "UPDATE $wpdb->postmeta SET meta_value = %d WHERE meta_key = %s", 0, 'post_views_count' ) );

The problem is that the query updates all meta_value's of all my posts.

I've been looking for a way to update the meta_value of meta_key 'post_view_count' of posts present in the taxonomy 'cars' and whose term of this taxonomy is 'blue'.

That way I can avoid updating the 'post_view_count' of 'red' (term) 'cars' (taxonomy), for example.

Answers (2)


dimadin answers:

I am quite sure that I know the answer and I know for sure what you've been doing wrong in any way (look at my profile for my previous work), but I can't work for such a low, almost non-existing reward, if you want to increase it I can help you.


Rempty answers:

If you rise the reward we can help you.

A small hint for you:
Create a wp_query with a tax query and echo the SQL.