Get All IDs of Custom Post Type (3 posts)

  1. Leo Blanchette
    Posted 2 years ago #

    Whats a fast-efficient way to get all IDs of a custom post type?

    There could easily be 3000 posts, so I wanted to generate a light-weight array of just IDs.

  2. Pioneer Web Design
    Posted 2 years ago #

  3. Rajesh Soni
    Posted 2 years ago #

    This could be of help: http://codex.wordpress.org/Function_Reference/wp_count_posts

    OR this...

    $qry_args = array(
    		'post_status' => 'publish', // optional
    		'post_type' => 'your_post_type', // Change to match your post_type
    		'posts_per_page' => -1, // ALL posts
    	$all_posts = new WP_Query( $qry_args );
            echo "Total matching posts: $all_posts->found_posts";

Topic Closed

This topic has been closed to new replies.

About this Topic