I am writing a plugin in which I need to list post/page/attachment by each type.
First I get all post type:
$post_types = get_post_types (array('public'=>true));
Then I create a loop and query posts for each post type, and print out:
foreach ($post_types as $type_name => $post_type) : $args = array( 'post_type' => $post_type, 'numberposts' => -1, 'post_status' => null, 'post_parent' => null, // any parent ); $posts = get_pages($args); if ($posts): foreach ($posts as $post) : print_r($post); endforeach; endif; endforeach;
However, on plugin page, I don't see anything print out.
Could anyone please give a hint?
Thanks a lot!