WordPress.org

Ready to get started?Download WordPress

Forums

Custom Post Type Not Displaying All Posts In Admin (2 posts)

  1. Justin
    Member
    Posted 1 year ago #

    I have a hierarchical custom post type setup, and about 2,700 posts of that type in my WP install.

    $labels = array(
    		'name' => _x('Channels', 'post type general name'),
    		'singular_name' => _x('Channel', 'post type singular name'),
    		'add_new' => _x('Add New', 'Channel'),
    		'add_new_item' => __('Add New Channel'),
    		'edit_item' => __('Edit Channel'),
    		'new_item' => __('New Channel'),
    		'view_item' => __('View Channel'),
    		'search_items' => __('Search Channels'),
    		'not_found' =>  __('No Channels found'),
    		'not_found_in_trash' => __('No Channels found in Trash'),
    		'parent_item_colon' => ''
    	);
    
    	register_post_type( 'channel',
    		array(
      		'labels' => $labels,
      		'public' => true,
      		'hierarchical' => true,
      		'has_archive' => true,
      		'show_in_nav_menus' => true,
      		'rewrite' => array('slug' => 'channels'),
      		'menu_position' => 5,
      		'capability_type' => 'page',
      		'supports' => array('title', 'editor', 'thumbnail', 'page-attributes', 'genesis-layouts'),
    		)
    	);

    When I view the posts in my admin (/wp-admin/edit.php?post_type=channel), I see less than 100 posts. The top left shows the proper count:

    All (2,755) | Published (2,755) | Trash (0)

    The top right does not:

    88 items « ‹ 1 of 5 › »

    Any clues as to how to debug?

    It's worth noting: I have a custom field setup on all of these posts, and the ones that appear in the admin have a value of "1" for the meta_value. When I inspect the wp_query, though, there's no sort of meta filtering happening.

  2. Justin
    Member
    Posted 1 year ago #

    I came up with a hack to get things working.

    // hack to get all channels to appear
      if ( is_admin() ) {
        if ($query->is_main_query() && get_query_var('post_type') == 'channel' && $_SERVER['PHP_SELF'] == '/wp-admin/edit.php') {
          $query_str = "post_type=channel&post_status=publish&posts_per_page=20&orderby=title&order=asc";
    
          $fields = array('s', 'paged');
    
          foreach($fields as $field) {
            if (get_query_var($field)) {
              $query_str .= "&{$field}=" . urlencode(get_query_var($field));
            }
          }
    
          query_posts( $query_str );
          return $query;
        } else {
          return;
        }
      }

Topic Closed

This topic has been closed to new replies.

About this Topic