I'm writing a custom plugin that is initialized at init
. This plugin is trying to query for some custom post types already stored in the DB.
Here's my code:
$args = array()
$myposts = get_posts( $args );
print_r($myposts);
No matter what arguments I pass into the $args array I don't get anything. For example:
$args = array( 'post_type' => 'page' );
Now, to my confusion if I use the exact same arguments with get_pages()
I get a result.
Maybe this has something to do with when WP Query is initialized?
$myposts = get_posts( );
i.e. you're not passing$args
toget_posts()
?