Opened 20 months ago

Last modified 8 months ago

#18958 closed defect (bug)

Can't set "Show on screen" for Custom post types — at Version 8

Reported by: dd32 Owned by:
Priority: normal Milestone: 3.5
Component: Administration Version: 3.3
Severity: normal Keywords: has-patch early
Cc: stephenh1988, solaveritasteliberum@…

Description (last modified by dd32)

As above. The posts_per_page "show on screen" function on custom post pages doesn't apply/save.

Change History (10)

Seems okay here. What's the CPT name? Maybe the switch to sanitize_key() busted something.

Last edited 19 months ago by ryan (previous) (diff)
  • Keywords reporter-feedback added; needs-patch removed

comment:3 follow-up: ↓ 4   SergeyBiryukov19 months ago

With the "Book" CPT example from Codex, my results are a bit different.

On initial page load, all meta boxes are displayed, but only "Featured Image" is checked in "Show on screen" (see the screenshot). If I toggle the checkboxes, the changes seem to be applied correctly.

comment:4 in reply to: ↑ 3   SergeyBiryukov19 months ago

Replying to SergeyBiryukov:

On initial page load...

i.e. when there's no metaboxhidden_book record in wp_usermeta.

Happens in 3.2.1 as well.

Being called from meta_box_prefs() and do_meta_boxes(), get_hidden_meta_boxes() returns different results, due to different $screen values.

In meta_box_prefs(), it's:

WP_Screen Object( [id] => book, [base] => post, ... )

In do_meta_boxes(), it's:

stdClass Object( [id] => book, [base] => book )

Note the difference in base value.

Not sure what the preferred option is, but 18958.patch at least makes it consistent.

Ok so.. I'm shamed to say: I was using a CPT plugin to add the post type. Below is the call it's using, It's probably caused by the dash in the CPT name, in core we underscores, I'd say it's messing with the splitting on dashes which I believe the screen options stuff uses.

register_post_type('test-cpt', array(
  'label' => 'Test CPT',
  'description' => '',
  'public' => true,
  'show_ui' => true,
  'show_in_menu' => true,
  'capability_type' => 'post',
  'hierarchical' => true,
  'rewrite' => true,
  'query_var' => true,
  'has_archive' => true,
  'supports' => array('title','editor','excerpt','custom-fields','comments','revisions','page-attributes')
)
);

With this code, "Show on screen" also seems to work for me in current trunk (aside from the initial checkboxes inconsistency I've mentioned). The meta key saved is metaboxhidden_test-cpt.

Last edited 19 months ago by SergeyBiryukov (previous) (diff)
  • Description modified (diff)

Oh damn, Sorry I've missed one very important word in the original ticket, The posts per page field doesn't save.

Note: See TracTickets for help on using tickets.