• Resolved deezywonder

    (@deezywonder)


    I’m using my own theme and I’m facing a issue: when I create a custom post type, all posts and pages “dissapear” – they’re there, but I can’t edit them, etc. Someone knows why this happens? Screenshot:

    My custom post type code (functions.php):

    function profissoes_post_type() {
    
    	$labels = array(
    		'name'                  => _x( 'Profiss?es', 'Post Type General Name', 'empregalia' ),
    		'singular_name'         => _x( 'Profiss?o', 'Post Type Singular Name', 'empregalia' ),
    		'menu_name'             => __( 'Profiss?es', 'empregalia' ),
    		'name_admin_bar'        => __( 'Profiss?es', 'empregalia' ),
    		'archives'              => __( 'Item Archives', 'empregalia' ),
    		'attributes'            => __( 'Item Attributes', 'empregalia' ),
    		'parent_item_colon'     => __( 'Parent Item:', 'empregalia' ),
    		'all_items'             => __( 'All Items', 'empregalia' ),
    		'add_new_item'          => __( 'Add New Item', 'empregalia' ),
    		'add_new'               => __( 'Add New', 'empregalia' ),
    		'new_item'              => __( 'New Item', 'empregalia' ),
    		'edit_item'             => __( 'Edit Item', 'empregalia' ),
    		'update_item'           => __( 'Update Item', 'empregalia' ),
    		'view_item'             => __( 'View Item', 'empregalia' ),
    		'view_items'            => __( 'View Items', 'empregalia' ),
    		'search_items'          => __( 'Search Item', 'empregalia' ),
    		'not_found'             => __( 'Not found', 'empregalia' ),
    		'not_found_in_trash'    => __( 'Not found in Trash', 'empregalia' ),
    		'featured_image'        => __( 'Featured Image', 'empregalia' ),
    		'set_featured_image'    => __( 'Set featured image', 'empregalia' ),
    		'remove_featured_image' => __( 'Remove featured image', 'empregalia' ),
    		'use_featured_image'    => __( 'Use as featured image', 'empregalia' ),
    		'insert_into_item'      => __( 'Insert into item', 'empregalia' ),
    		'uploaded_to_this_item' => __( 'Uploaded to this item', 'empregalia' ),
    		'items_list'            => __( 'Items list', 'empregalia' ),
    		'items_list_navigation' => __( 'Items list navigation', 'empregalia' ),
    		'filter_items_list'     => __( 'Filter items list', 'empregalia' ),
    	);
    	$rewrite = array(
    		'slug'                  => 'profissoes',
    		'with_front'            => true,
    		'pages'                 => true,
    		'feeds'                 => true,
    	);
    	$args = array(
    		'label'                 => __( 'Profiss?o', 'empregalia' ),
    		'description'           => __( 'Post Type Description', 'empregalia' ),
    		'labels'                => $labels,
    		'supports'              => array( 'title', 'editor', 'thumbnail', 'custom-fields', 'page-attributes', 'post-formats' ),
    		'taxonomies'            => array( 'category', 'post_tag' ),
    		'hierarchical'          => true,
    		'public'                => true,
    		'show_ui'               => true,
    		'show_in_menu'          => true,
    		'menu_position'         => 5,
    		'menu_icon'             => 'dashicons-admin-tools',
    		'show_in_admin_bar'     => true,
    		'show_in_nav_menus'     => true,
    		'can_export'            => true,
    		'has_archive'           => true,
    		'exclude_from_search'   => false,
    		'publicly_queryable'    => true,
    		'rewrite'               => $rewrite,
    		'capability_type'       => 'page',
    	);
    	register_post_type( 'post_type', $args );
    
    }
    add_action( 'init', 'profissoes_post_type', 0 );

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter deezywonder

    (@deezywonder)

    I found the issue: Just changed

    register_post_type( 'post_type', $args );
    threadi

    (@threadi)

    Your post type has the name “post_type”. It’s protected. You should choose a different one, e.g. “custom_post_type” or something that also fits thematically.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘When I create a custom post type, all posts dissapear’ is closed to new replies.