• Resuelto Jonatan Weber

    (@jwebers)


    Hola, tengo una web la cual he creado un CPT llamado pulseras-actividad, este CPT arroja una pagina de resumen de los post contenidos en el CPT. Pero yo quiero que en vez de una pagina resumen, me entregue una pagina tipo landing page que tengo ya creada en paginas. Esta pagina se llama pulseras-actividad.
    He conseguido que todo funcione bien si le cambio el nombre y le pongo otro. Pero si se llama igual que es lo que me gustaría para que mantenga una estructura jerárquica me muestra el resumen de post por defecto.
    Probe a hacer un 301 de pulseras-actividad a pulsera de actividad y valía para acceder a la pagina desde la Home pero al intentar entrar en un post daba error 310 excesivas redirecciones.
    Otro problema es que en el sitemap que me genera Yoast ahora hay dos paginas que se llaman igual y con diferente contenido.
    El custom lo tengo en un plugin, os dejo el código:
    <?php
    /*
    Plugin Name: JWS Functions
    Plugin URI: https://teactivas.com/
    Description: Plugin para funciones de WP personalizadas
    Version: 1.0
    Author: Jonatan Weber
    Author URI: https://teactivas.com
    License: GPLv2 o posterior
    */
    if ( ! function_exists(‘custom_post_pulseras’) ) {

    // Register Custom Post Type
    function custom_post_pulseras() {

    $labels = array(
    ‘name’ => _x( ‘Pulseras’, ‘Post Type General Name’, ‘text_domain’ ),
    ‘singular_name’ => _x( ‘Pulsera’, ‘Post Type Singular Name’, ‘text_domain’ ),
    ‘menu_name’ => __( ‘Pulseras’, ‘text_domain’ ),
    ‘name_admin_bar’ => __( ‘Pulseras’, ‘text_domain’ ),
    ‘archives’ => __( ‘Item Archives’, ‘text_domain’ ),
    ‘attributes’ => __( ‘Item Attributes’, ‘text_domain’ ),
    ‘parent_item_colon’ => __( ‘Parent Item:’, ‘text_domain’ ),
    ‘all_items’ => __( ‘Articulos’, ‘text_domain’ ),
    ‘add_new_item’ => __( ‘Añadir nuevo articulo’, ‘text_domain’ ),
    ‘add_new’ => __( ‘Añadir nuevo’, ‘text_domain’ ),
    ‘new_item’ => __( ‘Nuevo articulo’, ‘text_domain’ ),
    ‘edit_item’ => __( ‘Editar articulo’, ‘text_domain’ ),
    ‘update_item’ => __( ‘subir articulo’, ‘text_domain’ ),
    ‘view_item’ => __( ‘Ver articulo’, ‘text_domain’ ),
    ‘view_items’ => __( ‘Ver articulos’, ‘text_domain’ ),
    ‘search_items’ => __( ‘Búscar articulo’, ‘text_domain’ ),
    ‘not_found’ => __( ‘Nada’, ‘text_domain’ ),
    ‘not_found_in_trash’ => __( ‘Nada en la papelera’, ‘text_domain’ ),
    ‘featured_image’ => __( ‘Imagen destacada’, ‘text_domain’ ),
    ‘set_featured_image’ => __( ‘Set featured image’, ‘text_domain’ ),
    ‘remove_featured_image’ => __( ‘Borrar imagen’, ‘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’ => __( ‘Pulsera’, ‘text_domain’ ),
    ‘description’ => __( ‘Pulseras de actividad’, ‘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,
    ‘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’ => ‘page’,
    );
    register_post_type( ‘pulseras-actividad’, $args );

    }
    add_action( ‘init’, ‘custom_post_pulseras’, 0 );

    }

    //selecciona la pagina padre

    define( ‘STAFF_PAGE_PARENT_43’, ‘2’ );

    add_action( ‘wp_insert_post_data’, ‘saveStaffParent’, ’99’, 2 );

    function saveStaffParent( $data, $postarr ) {
    global $post;

    if ( !wp_verify_nonce( $_POST[‘staff_parent_custom_box’], ‘stc_cpt’ ) )
    return $data;

    // verify if this is an auto save routine.
    // If it is our form has not been submitted, so we dont want to do anything
    if ( defined( ‘DOING_AUTOSAVE’ ) && DOING_AUTOSAVE )
    return $data;

    if ( $post->post_type == «staff» ){
    $data[‘post_parent’] = STAFF_PAGE_PARENT_43;
    }

    return $data;
    }

    add_action( ‘template_redirect’, ‘fq_disable_single_cpt_views’ );

    // Divi Builder on custom post types
    add_filter(‘et_builder_post_types’, ‘divicolt_post_types’);
    add_filter(‘et_fb_post_types’,’divicolt_post_types’ ); // Enable Divi Visual Builder on the custom post types
    function divicolt_post_types($post_types)
    {
    foreach (get_post_types() as $post_type) {
    if (!in_array($post_type, $post_types) and post_type_supports($post_type, ‘editor’)) {
    $post_types[] = $post_type;
    }
    }
    return $post_types;
    }
    add_action(‘add_meta_boxes’, ‘divicolt_add_meta_box’);
    function divicolt_add_meta_box()
    {
    foreach (get_post_types() as $post_type) {
    if (post_type_supports($post_type, ‘editor’) and function_exists(‘et_single_settings_meta_box’)) {
    $obj= get_post_type_object( $post_type );
    add_meta_box(‘et_settings_meta_box’, sprintf(__(‘Divi %s Settings’, ‘Divi’), $obj->labels->singular_name), ‘et_single_settings_meta_box’, $post_type, ‘side’, ‘high’);
    }
    }
    }
    add_action(‘admin_head’, ‘divicolt_admin_js’);
    function divicolt_admin_js()
    {
    $s = get_current_screen();
    if (!empty($s->post_type) and $s->post_type != ‘page’ and $s->post_type != ‘post’) {
    ?>
    <script>
    jQuery(function ($) {
    $(‘#et_pb_layout’).insertAfter($(‘#et_pb_main_editor_wrap’));
    });
    </script>
    <?php
    }
    }

    //Ocultar título en páginas
    function hidetitle_class($classes) {
    if ( is_page() ) :
    $classes[] = ‘hidetitle’;
    return $classes;
    endif;
    return $classes;
    }
    add_filter(‘post_class’, ‘hidetitle_class’);

    //* Eliminar CPT tipo project del tema Divi

    if ( ! function_exists( ‘et_pb_register_posttypes’ ) ) :
    function et_pb_register_posttypes() {
    global $wp_post_types;
    if ( isset( $wp_post_types[ $post_type ] ) ) {
    unset( $wp_post_types[ $post_type ] );
    return true;
    }
    return false;
    }

    endif;

    ?>

    El tema utilizado es divi y todo esta actualizado a la ultima versión.

    La página con la que necesito ayuda: [accede para ver el enlace]

Viendo 1 respuesta (de un total de 1)
  • Moderador LGrusin

    (@lgrusin)

    Puedes crear una plantilla de página y poner dentro lo que quieras.

    Exactamente no he entendido qué quieres mostrar en esa landing Page que tenga relación con el Custom Post type «Pulsera»

    Por favor, usa el botón code para poner código, de otra manera no saldrá bien.

    Un saludo

    • Esta respuesta fue modificada hace 6 años, 4 meses por LGrusin.
Viendo 1 respuesta (de un total de 1)
  • El debate ‘Pagina padre para un CPT’ está cerrado a nuevas respuestas.