Trying to put a variable inside of an array
-
I’ve got a loop that works, so I’ll just include the important parts. The question I have is more about PHP than WP, but hopefully someone has dealt with this before.
Basically what I’m trying to do is create an agenda page for a conference website. I’ve got a loop of agenda events, and each post has a custom field of ID values for speakers that will be speaking at each of those events. So i’ve got an event with an advanced custom field that has a value of ‘1027,965,963’. Hopefully this explains my question.
Why is it that THIS WORKS….
$post_list = array(1027,965,963); foreach( $post_list as $post_id ) : query_posts('p=' .$post_id . '&posts_per_page=-1'); while (have_posts()) : the_post();
But THIS only returns info on 1027 and stops there?
$speakers = '1027,965,963'; $post_list = array($speakers); foreach( $post_list as $post_id ) : query_posts('p=' .$post_id . '&posts_per_page=-1'); while (have_posts()) : the_post();
How can i put these comma separated ID’s into the array from a separate variable? Does it have something to do with being a string, and needing to convert it to something else? If so, what? Thanks for any help you can offer!
- The topic ‘Trying to put a variable inside of an array’ is closed to new replies.