Home › Forums › Support › Ver CPT propio en la lista de tipos de contenido del bloque Bucle de consulta
- This topic has 6 replies, 2 voices, and was last updated 2 years, 6 months ago by
Ying.
-
AuthorPosts
-
August 16, 2022 at 11:15 am #2314890
Antonio Farelo Serén
Buenas tardes,
Estoy intentando utilizar el bloque Bucle de consulta para mostrar un listado de CPT propio que se llama: custom_post_type_eventos
He utilizado el siguiente código generado con http://www.generatewp.com:
if ( ! function_exists('custom_post_type_eventos') ) { // Register Custom Post Type function custom_post_type_eventos() { $labels = array( 'name' => _x( 'Eventos', 'Post Type General Name', 'text_domain' ), 'singular_name' => _x( 'Evento', 'Post Type Singular Name', 'text_domain' ), 'menu_name' => __( 'Eventos', 'text_domain' ), 'name_admin_bar' => __( 'Admin Eventos', 'text_domain' ), 'archives' => __( 'Archivo de eventos', 'text_domain' ), 'attributes' => __( 'Atributos de eventos', 'text_domain' ), 'parent_item_colon' => __( 'Parent Item:', 'text_domain' ), 'all_items' => __( 'All Items', 'text_domain' ), 'add_new_item' => __( 'Añadir nuevo evento', 'text_domain' ), 'add_new' => __( 'Añadir nuevo', 'text_domain' ), 'new_item' => __( 'Nuevo evento', 'text_domain' ), 'edit_item' => __( 'Editar evento', 'text_domain' ), 'update_item' => __( 'Actualizar evento', 'text_domain' ), 'view_item' => __( 'Ver evento', 'text_domain' ), 'view_items' => __( 'Ver eventos', 'text_domain' ), 'search_items' => __( 'Buscar eventos', 'text_domain' ), 'not_found' => __( 'No encontrado', 'text_domain' ), 'not_found_in_trash' => __( 'No encontrado en papelera', 'text_domain' ), 'featured_image' => __( 'Imagen destacada', 'text_domain' ), 'set_featured_image' => __( 'Establecer Imagen destacada', 'text_domain' ), 'remove_featured_image' => __( 'Eliminar Imagen destacada', 'text_domain' ), 'use_featured_image' => __( 'Utilizar como Imagen destacada', 'text_domain' ), 'insert_into_item' => __( 'Insertar en un evento', 'text_domain' ), 'uploaded_to_this_item' => __( 'Subir a este evento', 'text_domain' ), 'items_list' => __( 'Lista de eventos', 'text_domain' ), 'items_list_navigation' => __( 'Navegación de lista de eventos', 'text_domain' ), 'filter_items_list' => __( 'Filtrar lista de eventos', 'text_domain' ), ); $rewrite = array( 'slug' => 'evento', 'with_front' => true, 'pages' => false, 'feeds' => true, ); $args = array( 'label' => __( 'Evento', 'text_domain' ), 'description' => __( 'Eventos', 'text_domain' ), 'labels' => $labels, 'supports' => array( 'title', 'editor', 'thumbnail', 'comments', 'trackbacks', 'revisions', 'custom-fields', 'page-attributes', 'post-formats' ), 'taxonomies' => array( 'category', 'post_tag' ), 'hierarchical' => false, 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'menu_position' => 5, '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( 'cptevento', $args ); } add_action( 'init', 'custom_post_type_eventos', 0 ); }
El caso es que al escoger el tipo de contenido en el bloque Bucle de consulta no me aparece este Custom Post Type, unicamente Páginas y Entradas.
¿Cómo podría hacer para que apareciese y poder utilizarlo?
Muchas gracias por su ayuda.
Atentamente,
Toni Farelo
August 16, 2022 at 11:25 am #2314897Ying
StaffCustomer SupportHi Toni,
It seems the code is missing
Show in REST API
setting, it has to be set totrue
.August 17, 2022 at 10:57 am #2315837Antonio Farelo Serén
Exacto!!!
Súper! Gracias!!
Un abrazo enorme.
August 17, 2022 at 11:10 am #2315846Antonio Farelo Serén
Sorry!! Una pregunta más.
Dicho cpt tiene campos personalizados añadidos con ACF. No puedo escoger estos campos ya que que no me aparecen en la lista de campos que recupera el bloque Bucle de consultas.
Existe alguna manera de que aparezcan? Esto sería ideal!
Muchas gracias por su ayuda.
August 17, 2022 at 2:50 pm #2315992Ying
StaffCustomer SupportIt’s the same thing, the Custom fields need to be set to
Ture
forShow in REST API
setting 🙂August 18, 2022 at 9:08 am #2316815Antonio Farelo Serén
Lo imaginaba… En principio he activado esa opción al crearlos con ACF. Por algún motivo no aparecen en la lista desplegable, ahora bien, si los escribo a mano funciona perfectamente.
Así que problema resuelto.
Muchísimas gracias por tu ayuda.
Atentamente,
August 18, 2022 at 11:21 am #2316923Ying
StaffCustomer SupportYou are welcome 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.