Custom Post Type Registration Function Hides Pages

ajwerth

I created a function to register custom post types but for some reason after I add this code the Pages, other Posts and Custom Field Groups, disappear from the admin of WordPress. Here is my Register Function.

// Register Custom Post Type
function property() {

    $labels = array(
        'name'                  => _x( 'Properties', 'Post Type General Name', 'text_domain' ),
        'singular_name'         => _x( 'Property', 'Post Type Singular Name', 'text_domain' ),
        'menu_name'             => __( 'Properties', 'text_domain' ),
        'name_admin_bar'        => __( 'Properties', 'text_domain' ),
        'archives'              => __( 'Property Archives', 'text_domain' ),
        'attributes'            => __( 'Property Attributes', 'text_domain' ),
        'parent_item_colon'     => __( 'Parent Item:', 'text_domain' ),
        'all_items'             => __( 'All Items', 'text_domain' ),
        'add_new_item'          => __( 'Add New Property', 'text_domain' ),
        'add_new'               => __( 'Add New', 'text_domain' ),
        'new_item'              => __( 'New Property', 'text_domain' ),
        'edit_item'             => __( 'Edit Property', 'text_domain' ),
        'update_item'           => __( 'Update Property', 'text_domain' ),
        'view_item'             => __( 'View Property', 'text_domain' ),
        'view_items'            => __( 'View Properties', 'text_domain' ),
        'search_items'          => __( 'Search Properties', 'text_domain' ),
        'not_found'             => __( 'Not found', 'text_domain' ),
        'not_found_in_trash'    => __( 'Not found in Trash', 'text_domain' ),
        'featured_image'        => __( 'Featured Image', 'text_domain' ),
        'set_featured_image'    => __( 'Set featured image', 'text_domain' ),
        'remove_featured_image' => __( 'Remove featured image', 'text_domain' ),
        'use_featured_image'    => __( 'Use as featured image', 'text_domain' ),
        'insert_into_item'      => __( 'Insert into item', 'text_domain' ),
        'uploaded_to_this_item' => __( 'Uploaded to this item', 'text_domain' ),
        'items_list'            => __( 'Items list', 'text_domain' ),
        'items_list_navigation' => __( 'Items list navigation', 'text_domain' ),
        'filter_items_list'     => __( 'Filter items list', 'text_domain' ),
    );
    $args = array(
        'label'                 => __( 'Property', 'text_domain' ),
        'labels'                => $labels,
        'supports'              => array( 'title', 'editor', 'thumbnail', 'custom-fields' ),
        'taxonomies'            => array( 'property_type' ),
        'hierarchical'          => false,
        'public'                => true,
        'show_ui'               => true,
        'show_in_menu'          => true,
        'menu_position'         => 5,
        'menu_icon'             => 'dashicons-admin-home',
        'show_in_admin_bar'     => true,
        'show_in_nav_menus'     => true,
        'can_export'            => true,
        'has_archive'           => true,
        'exclude_from_search'   => false,
        'publicly_queryable'    => true,
        'capability_type'       => 'post',
    );
    register_post_type( 'post_type', $args );

}
add_action( 'init', 'property', 0 );

I know its an issue with this function, because when I remove it the pages reappear.

andrea_19920611

you can't call a custom post "post_type" this is your issue, try to change the name of custom post.

register_post_type( 'something_else', $args );

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

WordPress Pagination with custom post type. URL to other pages?

From Dev

Wordpress: How to call a function through custom post type functions in a plugin?

From Dev

Wordpress: How to call a function through custom post type functions in a plugin?

From Dev

How to load certain scripts only on single pages of custom post type in wordpress?

From Dev

WP taxonomy used with custom-post type breaks my statics pages permalinks

From Dev

Wordpress post_type=post not excluding pages

From Dev

Add Custom Type to Rails User Registration

From Dev

Custom Permalink of Custom Post Type

From Dev

Custom Post Type permissions

From Dev

Custom Post type slider

From Dev

Custom post type - archive

From Dev

Custom Post Type error

From Dev

Looping a custom post type

From Dev

Custom post type - archive

From Dev

In WordPress how to add post to custom pages:

From Dev

Custom view hides UITableViewCell

From Dev

'WSGIRequest' object has no attribute 'post' with custom registration form

From Dev

Wordpress Custom Post Type categroies

From Dev

Date archives for custom post type

From Dev

Create a wordpress custom post type

From Dev

Change custom post type url

From Dev

Wordpress paginate custom post type

From Dev

WooCommerce products in Custom Post Type

From Dev

Wordpress custom post type logic

From Dev

Categories not filtering on custom post type

From Dev

Custom post type date output

From Dev

Archive for Custom post type categories

From Dev

Custom post type menu disappeared

From Dev

Custom Post Type templates not found