1. PROMO Upgrade to Pro Membership @ $99 / Lifetime & access all our 16+ premium Divi extensions: Divi Block, Carousel Toolkit, etc.LEARN MORE
Dismiss Notice
NEW Divi.Help Pro Carousel AI Toolkit - Magically turn your Divi design into carousel, simply by using our online toolkit. No plugins needed. Now it works with Divi 5 as well!Try our carousel AI toolkit
BEST Divi Block - A revolutionary drag & drop tool to easily mix & match 960+ premade blocks (Light & Dark) to kick start your Divi site design. Special module designs are included as well. Also newly added AI generator & color. Now it works with Divi 5 as well!
Learn More About Divi BlockFree Version ~ 340+ Free Blocks

Get Custom Post Type objects for filtrable porfolio module

Discussion in 'Free Divi Community Forum' started by SarisPi, Jan 30, 2018.

  1. SarisPi

    SarisPi New Member

    Hi everyone! I've created a custom post type name "cursos" and i want all this custom post type to show in the fioltrable porfolio module.
    This is my code:

    PHP:
    function curstom_post_type_cursos() {

        $labels = array(
            'name'                  => _x( 'Cursos', 'Post Type General Name', 'text_domain' ),
            'singular_name'         => _x( 'Curso', 'Post Type Singular Name', 'text_domain' ),
            'menu_name'             => __( 'Cursos', 'text_domain' ),
            'name_admin_bar'        => __( 'Cursos', 'text_domain' ),
            'archives'              => __( 'Archivos de cursos', 'text_domain' ),
            'attributes'            => __( 'Atributos de cursos', 'text_domain' ),
            'parent_item_colon'     => __( 'Curso padre', 'text_domain' ),
            'all_items'             => __( 'Todos los cursos', 'text_domain' ),
            'add_new_item'          => __( 'Añadir nuevo curso', 'text_domain' ),
            'add_new'               => __( 'Añadir nuevo', 'text_domain' ),
            'new_item'              => __( 'nuevo curso', 'text_domain' ),
            'edit_item'             => __( 'Editar curso', 'text_domain' ),
            'update_item'           => __( 'Actualizar curso', 'text_domain' ),
            'view_item'             => __( 'Ver curso', 'text_domain' ),
            'view_items'            => __( 'ver cursos', 'text_domain' ),
            'search_items'          => __( 'buscar curso', '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' => __( 'Quitar imagen destacada', 'text_domain' ),
            'use_featured_image'    => __( 'Usar como imagen destacada', 'text_domain' ),
            'insert_into_item'      => __( 'Insertar en el curso', 'text_domain' ),
            'uploaded_to_this_item' => __( 'Subir a este curso', 'text_domain' ),
            'items_list'            => __( 'Lista de cursos', 'text_domain' ),
            'items_list_navigation' => __( 'Items list navigation', 'text_domain' ),
            'filter_items_list'     => __( 'Filter items list', 'text_domain' ),
        );
        $rewrite = array(
            'slug'                  => 'cursos',
            'with_front'            => true,
            'pages'                 => true,
            'feeds'                 => true,
        );
        $args = array(
            'label'                 => __( 'Curso', 'text_domain' ),
            'description'           => __( 'CPT Cursos', 'text_domain' ),
            'labels'                => $labels,
            'supports'              => array( 'title', 'editor', 'thumbnail', 'comments', 'trackbacks', 'revisions', 'page-attributes' ),
            'taxonomies'            => array( 'category', 'post_tag' ),
            'hierarchical'          => true,
            'public'                => true,
            'show_ui'               => true,
            'show_in_menu'          => true,
            'menu_position'         => 5,
            'menu_icon'             => 'dashicons-welcome-learn-more',
            'show_in_admin_bar'     => true,
            'show_in_nav_menus'     => true,
            'can_export'            => true,
            'has_archive'           => false,
            'exclude_from_search'   => false,
            'publicly_queryable'    => true,
            'rewrite'               => $rewrite,
            'capability_type'       => 'page',
        );
        register_post_type( 'cursos', $args );

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


    /*ADDING DIVI FUNTIONALITY TO THE CUSTOM POST TYPE*/
    /* ADD DIVI BUILDER TO ALL POST TYPES*/
    function dpb_all_post_types( $post_types ) {

    $post_types = get_post_types();

    if ( $post_types ) { // If there are any custom public post types.
    foreach ( $post_types as $post_type ) {
    $post_types[] ='$post_type';

    return $post_types;
    }
    }
    }
    add_filter( 'et_builder_post_types', 'dpb_all_post_types' );


    /*ADD DIVI META BOX */
    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
        
    }
    }
     
    1. PRO MEMBER PERKS Divi.Help Layout AI Generator - Try the power of AI to generate a custom Divi layout for you:Try Now
  2. Clint Sanchez

    Clint Sanchez New Member
    Divi Ultimate Child Theme Divi Powerful Child Theme Divi Ultimate Archive Plugin Divi Ultimate Blog Plugin Divi Ultimate Header Plugin Divi Ultimate Footer Plugin

    This is neat, I'd love to know more about how to make something like this for a business directory.