1

This is my WP_Query instruction but this not work. This display just first post. Help me please?

    // WP_Query arguments
    $args = array (
        'post_type' => 'teachers',
        'p' => '100, 102, 105'          <----------
    );

    // The Query
    $filter = new WP_Query( $args );

    // The Loop
    if ( $filter->have_posts() ) { ...

1 Answer 1

2

The p (post) paremeter for WP_Query accetps a single value only:

$args = array(
    'p' => 100
);

For multiple posts use post__in and pass an array of post ids:

$args = array(
    'post__in' => array(100, 102, 105)
);

See Post & Page Paremters for further clarification.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.