This must be fairly simple, but I'm puzzled. And I may be going about it backwards.
How do I output a database option that is an array into a get_posts array?
I have an option in the database that stores some post IDs in the array format `1234,5678' . I can retrieve and echo them with
$options = get_option( 'pu_theme_options' );
$newspostids = $options['pu_textbox'];
echo $newspostids;
so I know am getting the output `1234,5678'. The database "option" is just text, saved from a form field in theme options.
What I need to do is get the data from that option into a get_posts
array so I can display the posts by ID.
What I need is for get_posts
to function like this:
$news = get_posts( array(
'post_type' => 'post',
'post__in'=> array(1234,5678)
) );
And, obviously, this doesn't work, putting the variable directly into the array and expecting it to output `1234,5678' :
$news = get_posts( array(
'post_type' => 'post',
'post__in'=> array($newspostids)
) );
So how should this work?
explode(',', $option)
).. Can be confusing if you don't dump your data initially..