WordPress.org

Ready to get started?Download WordPress

Forums

Get All IDs of Custom Post Type (3 posts)

  1. Leo Blanchette
    Member
    Posted 1 year 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 Valley Web Design
    Member
    Posted 1 year ago #

  3. Rajesh Soni
    Member
    Posted 1 year 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