Multiple meta query from array

$search_term is already an array of an array. When you eventually add that to your meta_query, you get an array of an array of an array, which will not work You are using AND as your relation operator which is the default for a multi-array meta_query. I would suggest that you drop that, and then … Read more

Exclude specific user_id from args in get_comments

Looks like I had to figure this one out myself. replace $comment_meta_args and $replies with global $wpdb; $comment_meta_args=”SELECT * FROM `$wpdb->comments` WHERE `comment_approved` = 1 AND `comment_parent` = (“. intval($parent_comment_id) .”) AND `user_id` != 1 ORDER BY comment_date ASC LIMIT 3″; $replies=$wpdb->get_results($comment_meta_args);

add the value of a variable returned in a while loop [closed]

Try to change with this: …….. …….. …….. $fullcost = 0; while( $connected->have_posts() ) : $connected->the_post(); $cost = get_post_meta( $post->ID, ‘foxware-ingredient-cost’, true ); $fullcost += $cost; echo ‘<li>’; the_title(); // Display cost echo ‘<br>’; echo ‘Cost: ‘ . $cost; echo ‘</li>’; endwhile; echo $fullcost; ?>

Only load certain artists on this page

if you want to show only 2, put it as a value, like so: ‘posts_per_page’ => 2 For the newest posts, you need to change the sort using the order and orderby params: ‘orderby’ => ‘date’, ‘order’ => ‘ASC’ Details about orderby params here: http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters Also, you should avoid the query_posts use. Except if you … Read more

Query using string from custom field as array value

Okay anyone wanting to achieve this, the code works. Just save the values in the custom field without quotes. e.g. red, car <?php $list = get_field( “main_attributes” ); $array = explode(‘,’, $list); $args = array( ‘meta_query’ => array( ‘relation’ => ‘OR’, array( ‘key’ => ‘style_atrributes’, ‘value’ => $array, ‘compare’ => ‘IN’ ), array( ‘key’ => … Read more

Can’t add classes using jQuery from a JSON string with get_body_class()

get_body_class() is going to return an array of classes, which is then (per code not published in your question) JSON encoded into that comma separated string. While you can manipulate that in JavaScript, the easiest thing to do is implode the string before encoding: $c = get_body_class(‘project’); $c = implode($c,’ ‘); You should have a … Read more

Getting Category Children

The child_of parameter excepts an integer value of the specific term you need to get descendants from. This means that you need to get the ID from the On-going category term and then passing that ID to the child_of parameter. To note, the child_of parameter returns all descendants of the term passed, this includes direct … Read more

How can you query posts by advance custom field when the value is a serialized array? [closed]

I would advise using the built-in ACF functions for this. Elliot has provided a full toolbox for you and documentation for all field types: <?php // Conditional statement (Single Value) if(get_field(‘page_layout’) == “col_1”) { //… } //Conditional statement (Multiple Values) if( in_array( ‘col_1’, get_field(‘page_layout’) ) ) { //… } ?> Check out the ACF documentation: … Read more

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