WordPress Shortcode array issue

This is how to shortcode looks [posts3col ids="249, 318, 93" category="Events"]

And this is some of the code behind it, where I have the problem:

Read More
add_shortcode('posts3col', 'posts_func');

function posts_func($atts){
    extract(shortcode_atts(array(
        'ids'=> '',
        'category' => ''        
    ), $atts));

    $options=array(
            'posts_per_page' => 3,
            'category_name' => $category,
            'post__in' => array($ids)
            );
    ob_start(); 
    // run the loop based on the query
    $query = new WP_Query( $options ); .....

The problem I have is with ‘post__in’, I don’t know how to give it the ids.
If I write the ids manually in the code like this:

'post__in' => array(249, 318, 93)

it works, but obviously I need to pull the ids from the shortcode I can’t insert them manually.

Related posts

Leave a Reply

1 comment