Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Added another option that didn't work.
Source Link
tklodd
  • 129
  • 6

How do I use get_posts to filter against a single post id? (I don't want to use get_post because am using this in another function that could take other parameters and should return an array). The following methods are not working:

get_posts(array(
    'ID' => 12345,
));

get_posts(array(
    'p' => 12345,
));

get_posts(array(
    'post' => 12345,
)); 

get_posts(array(
    'post__in' => array(12345),
));

How do I use get_posts to filter against a single post id? (I don't want to use get_post because am using this in another function that could take other parameters and should return an array). The following methods are not working:

get_posts(array(
    'ID' => 12345,
));

get_posts(array(
    'p' => 12345,
));

get_posts(array(
    'post' => 12345,
));

How do I use get_posts to filter against a single post id? (I don't want to use get_post because am using this in another function that could take other parameters and should return an array). The following methods are not working:

get_posts(array(
    'ID' => 12345,
));

get_posts(array(
    'p' => 12345,
));

get_posts(array(
    'post' => 12345,
)); 

get_posts(array(
    'post__in' => array(12345),
));
Source Link
tklodd
  • 129
  • 6

How to use get_posts to filter against a single post id?

How do I use get_posts to filter against a single post id? (I don't want to use get_post because am using this in another function that could take other parameters and should return an array). The following methods are not working:

get_posts(array(
    'ID' => 12345,
));

get_posts(array(
    'p' => 12345,
));

get_posts(array(
    'post' => 12345,
));