Forums

[resolved] Query Posts with custom posts type and post__in (2 posts)

  1. Nilav
    Member
    Posted 1 year ago #

    Hi,

    I try to generate a query :

    <?php query_posts(array( 'post_type' => array( 'developer-editor' ), 'orderby' => 'title', 'order' => 'ASC', 'post__in' => array($developer_id) ) ); ?><?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    ...

    Where $developer_id='9313,9349'

    So, I should see two posts but only first ID is present. But, if I change $developer_id directly by 9313,9349. That's work ! But I can't do that in reality. I need to use $developer_id.

    I did an echo on $developer_id to check if it works. It's ok, I have my two ID : 9313,9349. So, I don't understand where is my mistake. A bad interpretation of the comma ?

  2. Nilav
    Member
    Posted 1 year ago #

    Pfff, That's work with a explode function

    Results :
    <?php query_posts(array( 'post_type' => array( 'developer-editor' ), 'orderby' => 'title', 'order' => 'ASC', 'post__in' => explode(',',$developer_id), ) ); ?><?php if (have_posts()) : while (have_posts()) : the_post(); ?>

    I will reflect 2 minutes more before to post my problem the next time. :D

Topic Closed

This topic has been closed to new replies.

About this Topic