How to check if the postID is in an array? [closed]

As Sally highlights, you can use in_array() like this (untested): // target ids $ids = array(123, 321, 213); if (!empty($post->ID) && is_numeric($post->ID) && in_array((int)$post->ID, $ids)) { // do jazz } else { // do stuff }

Printing out JSON array returned [closed]

Setting the proper dataType for the request is an important detail not considered in the answer above (this causes jQuery to send a HTTP Accept header with the request – and it will be expecting JSON data in the success callback as well): dataType: ‘json’, success:function(json){ var content=””; jQuery.each(json, function(i, v){ content += ‘<li>’ + … Read more

Exclude a ‘portfolio’ custom category?

Please take a look at this example; $args = array( ‘post_type’ => ‘post’, ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘movie_genre’, ‘field’ => ‘slug’, ‘terms’ => array( ‘action’, ‘comedy’ ) ), array( ‘taxonomy’ => ‘actor’, ‘field’ => ‘id’, ‘terms’ => array( 103, 115, 206 ), ‘operator’ => ‘NOT IN’ //you must set the … Read more

How to print array of specific item

Not really a WordPress question, but I’ll bite. That data is JSON. To manipulate it with PHP you need to decode it with json_decode(). Then you can treat it as a PHP object. So to access the values you’d mention, and assuming the JSON is in a variable named $json: $object = json_decode( $json ); … Read more

How to set if meta_value is lower < than other meta_value in a get_posts array?

Use this type of code : $args = array( ‘author’ => $publisher_info->ID, ‘post_type’ => ‘post’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘type’, ‘field’ => ‘slug’, ‘terms’ => array( ‘campaign’ ), ) ), ‘meta_query’ => array( ‘relation’ => ‘AND’, array( ‘key’ => ‘status’, ‘value’ => ‘active’, ‘compare’ => ‘=’), array( ‘key’ => ‘B’, ‘value’ => ‘1’, … Read more

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