Support » Fixing WordPress » Custom Post Type With Hierarchical Set To True On Large Data Sets Breaks

  • So lets see if I can explain this in detail, first let me tell you that I have exactly 20,337 posts in my custom post type and the code to register that post type is below.

    register_post_type( 'tv_shows',
    				array(
    					'labels' => array(
    						'name' => __( 'Tv Shows' ),
    						'singular_name' => __( 'Tv Show' ),
    						'add_new' => _x('Add New', 'tv_shows'),
    						'add_new_item' => __("Add New Tv Show"),
    						'edit_item' => __("Edit Shows"),
    						'new_item' => __("New Show"),
    						'view_item' => __("View Show"),
    						'search_items' => __("Search Shows"),
    						'not_found' =>  __('No shows found'),
    						'not_found_in_trash' => __('No shows found in Trash')
    					),
    					'description' => __( 'Used to add television shows to your wordpress blog.' ),
    					'supports' => array( 'title', 'editor', 'thumbnail', 'page-attributes', 'custom-fields' ),
    					'taxonomies' => array( 'genres' ),
    					'hierarchical' => false,
    					'public' => true,
    					'has_archive' => true,
    					'rewrite' => array( 'slug' => 'shows' )
    				)
    			);

    Now in the admin panel when I click on my custom post type to view/edit/update those posts a typical list of 20 entries per page appears just like they should using the code I posted above, the code above as it stands works 100%.

    However when I change the hierarchical option to true, things go haywire, when this option is set to true (Yes I need, well really want it set to true) WordPress seemly skips out on paging and attempt to load all 20,337 records on the same page instead of just 20 with paging like it does with the code above.

    At first I thought ok well this might be caused from having all my menu_order options set to true (Yes oops my bad when populating the database), so what I did was make all the menu_order fields unique as they would normally appear adding all entries by hand and this didn’t help either.

    So my question is when using large custom data sets with hierarchical set to true, does anyone know how to make it page inside of the admin panel and not attempt to open up all records on the same page.

    This might even be a bug because it sure does boggle my mind, I’ve been developing websites for 10+ years and been customizing and working with WordPress for many of those years but my mind is fried on this one haha.

    Thanks in advance for any help.

    P.S. If you are confused by what I wrote or need more clarification, please feel free to say so and feel free to use complex terminology, I’ve been around the block a few times and can handle what you toss at me :).

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter phrikk

    (@phrikk)

    P.P.S – When I said “At first I thought ok well this might be caused from having all my menu_order options set to true” above I meant to say “At first I thought ok well this might be caused from having all my menu_order options set to 0 (or the same value)”

    Thread Starter phrikk

    (@phrikk)

    I found something very interesting to prove my point, I created a new test custom post type and added just over 3000 records to it and set the hierarchical parameter in register_post_type to true.

    When I loaded up the admin panel page to manage it, I printed out the $wpdb object to see if there were any differences between having hierarchical set to true or false.

    I found out that when hierarchical is set to false the last query paramater in the $wpdb object reads like this
    [last_query] => SELECT post_id, meta_key, meta_value FROM wp_postmeta WHERE post_id IN (20394,20395,20396,20397,20398,20399,20400,20401,20402,20403,20404,20405,20406,20407,20408,20409,20410,20411,20412,20413)

    Where it only executes 20 posts, which is what it is supposed to do however when I change the hierarchical paramater to true and print out the $wpdb object then that same last_query paramater doesn’t show just 20 returned results, instead it shows all 3000+ returned results.

    This is a major issue for me with my 20,000+ database entries in my other post_type because that page doesn’t even load it simply just heads off to the cool allocate me some more memory page (If you develop large amounts of information, you know what I’m talking about lol).

    So that is just extra proof that when the hierarchical paramater is set to true, it attempts to read all post_meta data from ALL records and ignores any sort of paging which in my case kills everything but everything works correctly and does not ignore paging when hierarchical is set to false.

    Hope that makes sense and if you have any suggestions please hit me up.

    I think I have the same issue. I get a server error when I try and view /edit.php?post_type=custom_post_type just after about 3000 entries with hierarchy set to true. Changing to false males everything work. Did you ever find a solution for this?

    It seems similar to this but the permalink structure doesn’t seem to affect anything.

    http://digwp.com/2011/06/dont-use-postname/

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom Post Type With Hierarchical Set To True On Large Data Sets Breaks’ is closed to new replies.