i am trying to get posts by multiple posts slugs, i can do this by passing post ids but I do not want to pass post ids i am looking for posts slug

Here is my code

$option = array(
'posts_per_page' => -1,
'post_type' => 'post',
'name' => 'berlin, frankfurt, munich, augsburg'

$new_query = new WP_Query($option);
if ($new_query->have_posts()) {
while ($new_query->have_posts()) {
/* my html stuff */

but it does not display anything but when i pass only "berlin" then queyr gives me correct results. it mean i only need to use post ids to get selected multiple posts ?

  • When in doubt, it's always good to check the Codex on WP_Query.
    – birgire
    May 29, 2016 at 14:13

1 Answer 1


Try to put your post slugs in an array for the post_name__in parameter:

'post_name__in' => [ 'berlin', 'frankfurt', 'munich', 'augsburg' ],

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