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.

2
  • 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. Commented Nov 11, 2014 at 13:29
  • sorry, I meant posts of the tax. Thanks for asking. Commented Nov 12, 2014 at 13:46

1 Answer 1

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.

0

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.