archive true but posttype not viewed in list
-
My custom post type has the archive option true, but still it is not on the list.
only articles and pages …what are the default options the plug needs to be in the list?
-
The post type needs to be public and has is_archive set to true.
@helle1 did that help you out?
Hello,
I have the same problem. My code for creating Post Type looks like this:$args = array( 'label' => __( 'Programa', 'text_domain' ), 'description' => __( 'Programas do Pró-Saber', 'text_domain' ), 'labels' => $labels, 'supports' => array( 'title', 'editor', 'thumbnail' ), 'taxonomies' => array( 'category', 'post_tag' ), 'hierarchical' => false, 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'menu_position' => 5, 'menu_icon' => 'dashicons-smiley', 'show_in_admin_bar' => true, 'show_in_nav_menus' => true, 'can_export' => true, 'has_archive' => true, 'exclude_from_search' => false, 'publicly_queryable' => true, 'query_var' => 'programas', 'rewrite' => $rewrite, 'capability_type' => 'page', );
but this Custom Post type is not appearing in the block listing: https://ibb.co/wQTphw8
how should I proceed?
thanks!How are you registering your post type? Are you using the
init
hook?Hello!
Here is the full code:function post_type_programas() { $labels = array( 'name' => _x( 'Programas', 'Post Type General Name', 'text_domain' ), 'singular_name' => _x( 'Programa', 'Post Type Singular Name', 'text_domain' ), 'menu_name' => __( 'Programas', 'text_domain' ), 'name_admin_bar' => __( 'Programas', 'text_domain' ), 'archives' => __( 'Arquivo de Programas', 'text_domain' ), 'attributes' => __( 'Atributos de Programas', 'text_domain' ), 'parent_item_colon' => __( 'Item Pai:', 'text_domain' ), 'all_items' => __( 'Todos os Itens', 'text_domain' ), 'add_new_item' => __( 'Adicionar novo Item', 'text_domain' ), 'add_new' => __( 'Adicionar novo', 'text_domain' ), 'new_item' => __( 'Novo Item', 'text_domain' ), 'edit_item' => __( 'Editar Item', 'text_domain' ), 'update_item' => __( 'Atualizar Item', 'text_domain' ), 'view_item' => __( 'Ver Item', 'text_domain' ), 'view_items' => __( 'Ver Itens', 'text_domain' ), 'search_items' => __( 'Buscar Item', 'text_domain' ), 'not_found' => __( 'N?o Encontrado', 'text_domain' ), 'not_found_in_trash' => __( 'N?o Encontrado na Lixeira', 'text_domain' ), 'featured_image' => __( 'Imagem em Destaque', 'text_domain' ), 'set_featured_image' => __( 'Escolher Imagem em Destaque', 'text_domain' ), 'remove_featured_image' => __( 'Remover Imagem em Destaque', 'text_domain' ), 'use_featured_image' => __( 'Usar como Imagem em Destaque', 'text_domain' ), 'insert_into_item' => __( 'Inserir no 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' ), ); $rewrite = array( 'slug' => 'programas', 'with_front' => true, 'pages' => true, 'feeds' => true, ); $args = array( 'label' => __( 'Programa', 'text_domain' ), 'description' => __( 'Programas do Pró-Saber', 'text_domain' ), 'labels' => $labels, 'supports' => array( 'title', 'editor', 'thumbnail' ), 'taxonomies' => array( 'category', 'post_tag' ), 'hierarchical' => false, 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'menu_position' => 5, 'menu_icon' => 'dashicons-smiley', 'show_in_admin_bar' => true, 'show_in_nav_menus' => true, 'can_export' => true, 'has_archive' => true, 'exclude_from_search' => false, 'publicly_queryable' => true, 'query_var' => 'programas', 'rewrite' => $rewrite, 'capability_type' => 'page', ); register_post_type( 'programas', $args ); } add_action( 'init', 'post_type_programas', 0 );
thanks a lot!
Weird. I installed your code in functions.php for the Twenty Nineteen theme and it showed up fine.
hi!
I changed to another theme and still got the same error … do you believe this may be occurring because I have the site on localhost?I may need to troubleshoot via a google hangout. The plugin works fine on a localhost.
Can you please join this hangout? https://hangouts.google.com/call/9Gf_eGW8Z_U-imrnVk4QAEEE
You’ll want to add
'show_in_rest' => true,
to your post type initialization as well.It worked! thank you very much for your help. Could you give me your email? I am always in need of programmers who understand WordPress
thanksthanks!
Hi, having the same issue here. I have set ‘show_in_rest’ => true, but it didn’t help like in the previous case above.
Here is my CPT:
function create_posttype() {
register_post_type( ‘works’,
// CPT Options
array(
‘labels’ => array(
‘name’ => __( ‘Works’ ),
‘singular_name’ => __( ‘Work’ )
),
‘public’ => true,
‘has_archive’ => true,
‘rewrite’ => array(‘slug’ => ‘works’),
)
);
}
// Hooking up to theme setup
add_action( ‘init’, ‘create_posttype’ );/*
* Creating a function to create our CPT
*/function custom_post_type() {
// Set UI labels for Custom Post Type
$labels = array(
‘name’ => _x( ‘Works’, ‘Post Type General Name’, ‘fstheme’ ),
‘singular_name’ => _x( ‘Work’, ‘Post Type Singular Name’, ‘fstheme’ ),
‘menu_name’ => __( ‘Works’, ‘fstheme’ ),
‘parent_item_colon’ => __( ‘Parent Work’, ‘fstheme’ ),
‘all_items’ => __( ‘All Works’, ‘fstheme’ ),
‘view_item’ => __( ‘View Work’, ‘fstheme’ ),
‘add_new_item’ => __( ‘Add New Work’, ‘fstheme’ ),
‘add_new’ => __( ‘Add New’, ‘fstheme’ ),
‘edit_item’ => __( ‘Edit Work’, ‘fstheme’ ),
‘update_item’ => __( ‘Update Work’, ‘fstheme’ ),
‘search_items’ => __( ‘Search Work’, ‘fstheme’ ),
‘not_found’ => __( ‘Not Found’, ‘fstheme’ ),
‘not_found_in_trash’ => __( ‘Not found in Trash’, ‘fstheme’ ),
);// Set other options for Custom Post Type
$args = array(
‘label’ => __( ‘works’, ‘fstheme’ ),
‘description’ => __( ‘Fredrik Sixten Works’, ‘fstheme’ ),
‘labels’ => $labels,
// Features this CPT supports in Post Editor
‘supports’ => array( ‘title’, ‘editor’, ‘excerpt’, ‘thumbnail’, ‘revisions’, ),
// You can associate this CPT with a taxonomy or custom taxonomy.
‘taxonomies’ => array( ‘works_categories’ ),
/* A hierarchical CPT is like Pages and can have
* Parent and child items. A non-hierarchical CPT
* is like Posts.
*/
‘hierarchical’ => false,
‘public’ => true,
‘show_ui’ => true,
‘show_in_menu’ => true,
‘show_in_nav_menus’ => true,
‘show_in_rest’ => true,
‘show_in_admin_bar’ => true,
‘menu_position’ => 10,
‘can_export’ => true,
‘has_archive’ => true,
‘exclude_from_search’ => false,
‘publicly_queryable’ => true,
‘capability_type’ => ‘post’,
);// Registering your Custom Post Type
register_post_type( ‘works’, $args );}
Found my error. Sorry.
- The topic ‘archive true but posttype not viewed in list’ is closed to new replies.