use get_posts to get custom field data, but in one array

You can alter your foreach loop as following to get concert date and city pair in single multidimentional array as following. $concert_query = array(); $i = 0; foreach($c_query as $post) : setup_postdata($post); $concert_query[$i][‘concert_date’] = get_post_meta(get_the_ID(), ‘concert_date’, true); $concert_query[$i][‘concert_city’] = get_post_meta(get_the_ID(), ‘concert_city’, true); $i ++; endforeach; print_r($concert_query);

Make Selected Mutiselect Items “selected”

I’m assuming your $selected variable contains an array of values for the currently selected items? You can’t use selected in this case (with multi select boxes) because it only compares two strings. It won’t test to see if the value is in an array. Instead, use a ternary statement and in_array() <?php foreach ($cats as … Read more

Creating a unique, linked list of tags from a specific category?

You can build a stack of unique tags, then loop over them again to output. Couple of extra things though – never use query_posts. Secondly, you can be way more efficient in your querying and save a lot of memory in the process: $post_ids = get_posts( array( ‘posts_per_page’ => -1, ‘category_name’ => ‘testing’, ‘fields’ => … Read more

post__in works but also prints the word Array

Array is how PHP represents an array when it is converted to a string: echo array( /* anything in here */ ); // output: Array Fortunately for you, PHP doesn’t really like converting arrays to strings, so it will give an error like this: PHP Notice: Array to string conversion in /somefile.php on line 345 … Read more

Updata Metadata WP Rest API

Two things need to be changed 1 – wishlistPost.metadata.wishlist_array which is the metadata returns an object with a string inside, not an array. var wishlist_array = wishlistPost.metadata.wishlist_array[0]; //Get current string wishlist_array += postID + “,”; //Concat new ID to the current string 2 – JSON.stringify(wishlist_array) is not needed as stated above wishlist_array is a string … Read more