0

Today I have

<?php $loop = new WP_Query( array( 'post_type' => 'inspirations', 'posts_per_page' => 50 ) ); ?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>

which gives me all posts inside the tax inspiration - I need to alter this, so that I get only selected ID's in my array, ex. 4714, 3608, instead of all terms of the tax.

According to WP Query arguments I need to alter the code to:

<?php $loop = new WP_Query( array( 'post_in' => array(4174, 3608), 'posts_per_page' => 50 ) ); ?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>

But that does not return anything, not even a error.. What am I doing wrong here? :)

Thanks a lot for reading.

  • 1
    There is nothing in your code about terms, so I don't quite follow what do you mean around "all terms of the tax" part. – Rarst Nov 11 '14 at 13:29
  • sorry, I meant posts of the tax. Thanks for asking. – Athen Nov 12 '14 at 13:46
0

which gives me all posts inside the tax inspiration - I need to alter this, so that I get only selected ID's in my array, ex. 4714, 3608, instead of all terms of the tax.

I'm assuming you mean that this query gives you all posts inside post type inspiration and you want to pull specific post IDs instead of all posts of the post type. Taxonomies and Post Types. are two different things.

Try to alter your query to something like this:

$loop = new WP_Query( array(
    'post_type' => 'inspirations',
    'post__in' => array( 4174, 3608 )
));

The difference between this and your original loop is that 1) There is a post type defined and 2) post__in has 2 underscore where yours has 1. I removed the posts_per_page parameter as this query should only return 2 posts.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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