Forums

[resolved] How to make a sting to an array and use it in "post__in"? (5 posts)

  1. madebymads
    Member
    Posted 1 month ago #

    Hi!

    I'm trying not to go crazy here, but for the moment I'm very close, so if any one can help I'll be very happy.

    The problem is this:

    $showPost = get('slide_id',1,1,FALSE,$post->ID);
    $args = array(
    	'category_name' => 'slideshow',
    	array('post__in' => array($showPost)),
    	'showposts'=> -1,
    	'order' => 'DESC'
    	);

    The $showPost gets it's data from a custom field called slide_id (I use the magic fields plugin) and the string it puts out could be something like: 101,185,166

    The numbers is post id's that I want to be showen. My problem is that the $showPost don't make an array that wp like. I know that the $showPost is not an array to start with is just: 101,185,166 ect. But my guess was that when I wraped it in array() it would be one.

    What I'm going for is only to pull the post that I specify in the main post's custom field. And output the data befor the main loop in it's own WP_query and that work beside I can't specify the presice ID I want.

    Hope some can suppley a quick anwser, Mads

  2. MichaelH
    moderator
    Posted 1 month ago #

  3. apljdi
    Member
    Posted 1 month ago #

    $args = array(
            'category_name' => 'slideshow',
            'post__in' => explode(',',$showPost),
            'showposts'=> -1,
            'order' => 'DESC'
            );
  4. madebymads
    Member
    Posted 1 month ago #

    Thanks, I'll try that, but I'm all most cretin that I have tried that. But I'll give it another go.

    Thanks

  5. madebymads
    Member
    Posted 1 month ago #

    Wow, just got it to work. Must say I'm very thankful now I can get some sleep and still make the deadline. Just spend a whole work day trying to make this work :)

    If others need this, here my code, I change a FALSE to a 0 as well:

    $showPost = get('slide_id',1,1,0,$post->ID);
    
    $args = array(
    	'category_name' => 'slideshow',
    	'post__in' => explode(',', $showPost),
    	'showposts'=> -1,
    	'order' => 'date'
    	);

    Once again, thank you both.

    By the way check out http://magicfields.org for the plugin.

Reply

You must log in to post.

About this Topic