Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wordpress WP_Query call posts AND pages

Tags:

post

wordpress

I have a feature slider set up that draws in posts that are tagged 'feature'

$my_query = new WP_Query(array(
  'showposts' => 3,
  'tag'  => 'feature' ));

Is is possible to draw in posts AND pages? I know you can draw pages with 'post_type'=>'page' but can you mix the two?

like image 766
Mr Jonny Wood Avatar asked Dec 03 '22 06:12

Mr Jonny Wood


1 Answers

You can specify an array value for the post_type parameter, as such:

$my_query = new WP_Query(array(
    'post_type' => array('post', 'page'),
    'tag'  => 'feature'
));

See this page for more info: WP Codex

like image 54
fivedigit Avatar answered Dec 26 '22 01:12

fivedigit