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?
For anyone having to edit older code that doesn't use an array passed into WP_Query, you can add
&post_type=any
to get posts and pages (and other content). Unfortunately I don't see a way to get posts and pages (without other types) without using an array, since post_type would then require an array as the examples above show. However, this should be good enough if you are searching for a particular category anyway.Example (this from vSlider v4.1.2 where
&post_type=any
is added so that pages are included in the slider):Thanks to @fivedigit and @my-jonny-wood for the answers above that led me to figuring this out and fixing the slider on my site!
You can specify an array value for the
post_type
parameter, as such:See this page for more info: WP Codex
@fivedigit Thanks but I went with this in the end:
Although your version may come in handy in the future!
I am wanting to create 4 featured posts on the front page, would I create an array, then select the one I want in each div from there?