The following code in functions.php outputs a post when I publish, not a Page:
// custom post_type for agenda
add_action( 'init', 'create_my_post_types' );
function create_my_post_types() {
register_post_type( 'agenda', array(
'labels' => array(
'name_admin_bar' => _x( 'Agenda', 'add new on admin bar' ),
),
'public' => true,
'publicly_queryable' => false,
'capability_type' => 'page',
'map_meta_cap' => true,
'hierarchical' => true,
'rewrite' => false,
'query_var' => false,
'delete_with_user' => true,
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'page-attributes', 'custom-fields', 'comments', 'revisions' ),
) );}
What am I doing wrong?
The full problem:
I need to add a metabox to a page, but only the “agenda” page, I don’t want this metabox to appear in every page in admin panel, so I’m creating a custom post_type with the exact same functions of a page, only with a different post_type to be able to set a metabox to it alone.
Screenshot of current output:
http://i.stack.imgur.com/oPEx8.png
(can’t post direct images yet, so please click link)
Your screenshot seems to indicate that you’re interested in the status message for your custom post type saying
'Page updated. View page'
. If that’s true, the reason that you’re getting'Post updated. View post'
is that you haven’t provided status messages for your custom post type.Here’s the code for the admin edit page (
edit-form-advanced.php
):So the edit screen is trying to retrieve messages for your
$post_type
(agenda), not finding them, and displaying the post messages.You can fix this by creating
$messages['agenda']
with something like the approach described on the Register Post Type function reference:You Don’t need to create a custom post type just add the metabox if the page is the one you require ex: