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

How to include post count in this “get_tags” snippet

where exactly? example below is for the count getting shown in brackets after the tag name, outside the link: <?php $tags = get_tags(); if ($tags) { foreach ($tags as $tag) { echo ‘<li><a href=”‘ . get_tag_link( $tag->term_id ) . ‘” title=”‘ . sprintf( __( “View all posts in %s” ), $tag->name ) . ‘” ‘ … Read more

Accessing array elements (get_pages)

The return set of $children is an associative array. So you can get the IDs with: $children = get_children( $args ); foreach ($children as $k => $v) { echo $k; // do stuff with $v }

Accessing value from associative array

You’re doing one to many loops. What you want to be doing is this: $args = array( ‘child_of’ => $CurrentPage ); $children = get_pages( $args ); foreach ($children as $key => $value) { echo $key[‘post_title’]; }; Or you could also: $args = array( ‘child_of’ => $CurrentPage ); $children = get_pages( $args ); foreach ($children as … Read more

Echo custom field value in shortcode function

Try this code, I’ve removed query_posts and used get_posts instead because I’m not sure if query_posts will work in a shortcode and using get_posts is safer. function featured() { $posts = get_posts(array(‘post_type’ => ‘property’, ‘posts_per_page’ => 2)); if(isset($posts) && !empty($posts)) { foreach($posts as $post) { echo “<div class=\”singlefeatured group\”>”; //I wasn’t sure what you wanted … Read more

post custom values

Use var_dump($site[0]) to see the structure of the array. And once you know that, then you can properly reference an item in that array. (You could also do var_dump($site) to get a full picture of what’s going on.)