Make WordPress Core

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#27549 closed defect (bug) (duplicate)

register_post_type arguments producing unexpected output

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

Description

When setting up a custom post type with register_post_type() which includes the following arguments the custom post type will show regular posts instead of the custom post type. The arguments that seem to be causing the problem are:

'public' => false,
'publicly_queryable' => false,

I created the following plugin code to demonstrate the issue:

<?php
/*
Plugin Name: Broken Custom Posts Types Demo
*/

add_action( 'init', 'this_post_type_works' );

function this_post_type_works() {
	register_post_type( 'super_duper', 
		array(
			'labels' => array(
				'name' => __( 'Super Duper' ),
				'singular_name' => __( 'Super Duper' )
			),
			'public' => true,
			'show_ui' => true,
		)
	);
}


add_action( 'init', 'this_post_type_does_not_work' );

function this_post_type_does_not_work() {
	register_post_type( 'not_super', 
		array(
			'labels' => array(
				'name' => __( 'Not Super' ),
				'singular_name' => __( 'Not Super' )
			),
			'public' => false,
			'show_ui' => true,
			'publicly_queryable' => false,
		)
	);
}
?>

You should see that when your are in the WordPress Admin and you click on the 'Not Super' custom post type that regular posts are being returned instead of the 'Not Super' post type.

Change History (4)

#1 @stuartwider
11 years ago

Btw I'm testing on 3.9-beta2-27714, newly created site with no plugins active, default 2014 theme, on my test WP multisite setup.

#2 @stuartwider
11 years ago

Also just noticed that clicking on 'all pages' in the dash actually displays the list of regular posts. Looks like its a bigger issue.

#3 @nacin
11 years ago

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

Duplicate of #27547, fixed via #23862.

#4 @SergeyBiryukov
11 years ago

  • Component changed from Taxonomy to Posts, Post Types
Note: See TracTickets for help on using tickets.