Make WordPress Core

Opened 8 years ago

Closed 8 years ago

#30669 closed defect (bug) (worksforme)

Admin (edit.php). Wrong post type when using restrict_manage_posts for two taxonomies

Reported by: axeleus's profile axeleus Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.0.1
Component: Posts, Post Types Keywords:
Focuses: administration Cc:


I have custom post type "products" and two taxonomies (shoptag and shopcat).
I create 2 dropdown menu

  add_action( 'restrict_manage_posts', 'theme_restrict_manage_posts' );
  function theme_restrict_manage_posts() {
     global $typenow;
     if ($typenow == 'products') {

	$filters = array('shoptag', 'shopcat');

	foreach ($filters as $tax_slug) {
	    $tax_obj = get_taxonomy($tax_slug);
	    $tax_name = $tax_obj->labels->name;
            //echo dropdown

When I chose "shoptag" and clicked the filter, I see the results page. Then I chose another option of dropdown, clicked filter and I saw Error: "Invalid record type".

In wp-admin/edit.php at line 311

<input type="hidden" name="post_type" class="post_type_page" value="<?php echo $post_type; ?>" />

After manipulations described above in the "post_type" returned value="Array"

I print the value "post_type" at line 161 we are see "Array ( [0] => products )", but it should be "products". If we do to the same at line 159 everything will be fine we are see "products".

May be worth in the field "post_type" variable output $typenow at line 311?

<input type="hidden" name="post_type" class="post_type_page" value="<?php echo $typenow; ?>" />

Change History (1)

#1 @dd32
8 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from new to closed


With the code supplied, I'm unable to duplicate any issue.

It looks like it could possibly be related to something you have altering the WP_Query through pre_get_posts or similar.
If you're able to par down the code to a minimal example that can be used to reproduce this, feel free to re-open the ticket.

It's also possible that something is altering the global $post_type variable on the edit.php page view, which ideally shouldn't happen either.

Note: See TracTickets for help on using tickets.