Site logo

[Support request] Add meta to custom post type

Home Forums Support [Support request] Add meta to custom post type

Home Forums Support Add meta to custom post type

Viewing 15 posts - 1 through 15 (of 25 total)
  • Author
    Posts
  • #2041659
    Hilton

    Hi, I created a custom post type that has its own categories. I would like to know how I can display them below the custom posts.

    This is the function I use:

    function mefvideos_init() {
        // set up product labels
        $labels = array(
            'name' => 'Vídeos',
            'singular_name' => 'Vídeo',
            'add_new' => 'Add New Vídeo',
            'add_new_item' => 'Add New Vídeo',
            'edit_item' => 'Edit Vídeo',
            'new_item' => 'New Vídeo',
            'all_items' => 'All Vídeos',
            'view_item' => 'View Vídeo',
            'search_items' => 'Search Vídeos',
            'not_found' =>  'No Vídeos Found',
            'not_found_in_trash' => 'No Vídeos found in Trash', 
            'parent_item_colon' => '',
            'menu_name' => 'Vídeos',
        );
        
        // register post type
        $args = array(
            'labels' => $labels,
            'public' => true,
            'has_archive' => true,
            'show_ui' => true,
            'capability_type' => 'post',
            'hierarchical' => false,
            'rewrite' => array('slug' => 'videos'),
            'query_var' => true,
            'menu_icon' => 'dashicons-randomize',
            'supports' => array(
                'title',
                'editor',
                'excerpt',
                'trackbacks',
                'custom-fields',
                'comments',
                'revisions',
                'thumbnail',
                'author',
                'page-attributes'
            )
        );
        register_post_type( 'videos', $args );
        
        // register taxonomy
        register_taxonomy('videos_category', 'videos', array('hierarchical' => true, 'label' => 'Category', 'query_var' => true, 'rewrite' => array( 'slug' => 'videos-category' )));
    }
    add_action( 'init', 'mefvideos_init' );
    #2041665
    Ying
    Staff
    Customer Support
    #2041674
    Hilton

    Hi,

    I tried adding this to my functions.php, but didn’t work

    add_filter( 'generate_footer_meta_videos_types', function( $types ) {
        $types[] = 'videos';
    
        return $types;
    } );

    This is the page https://bit.ly/31BVyRx

    #2041680
    Ying
    Staff
    Customer Support

    You are not supposed to change the filter name: generate_footer_meta_post_types.

    Can you give it another try?

    #2041681
    Hilton

    Just to complement, this is the function I am using for creating CPT

    // Video Custom Post Type
    function mefvideos_init() {
        // set up video labels
        $labels = array(
            'name' => 'Vídeos',
            'singular_name' => 'Vídeo',
            'add_new' => 'Add New Vídeo',
            'add_new_item' => 'Add New Vídeo',
            'edit_item' => 'Edit Vídeo',
            'new_item' => 'New Vídeo',
            'all_items' => 'All Vídeos',
            'view_item' => 'View Vídeo',
            'search_items' => 'Search Vídeos',
            'not_found' =>  'No Vídeos Found',
            'not_found_in_trash' => 'No Vídeos found in Trash', 
            'parent_item_colon' => '',
            'menu_name' => 'Vídeos',
        );
        
        // register post type
        $args = array(
            'labels' => $labels,
            'public' => true,
            'has_archive' => true,
            'show_ui' => true,
            'capability_type' => 'post',
            'hierarchical' => false,
            'rewrite' => array('slug' => 'videos'),
            'query_var' => true,
            'menu_icon' => 'dashicons-video-alt3',
            'supports' => array(
                'title',
                'editor',
                'excerpt',
                'trackbacks',
                'custom-fields',
                'comments',
                'revisions',
                'thumbnail',
                'author',
                'page-attributes'
            )
        );
        register_post_type( 'videos', $args );
        
        // register taxonomy
        register_taxonomy('videos_category', 'videos', array('hierarchical' => true, 'label' => 'Category', 'query_var' => true, 'rewrite' => array( 'slug' => 'videos-category' )));
    }
    add_action( 'init', 'mefvideos_init' );
    
    //adicionar meta tags abaixo do video
    add_filter( 'generate_footer_meta_post_types', function( $types ) {
        $types[] = 'videos';
    
        return $types;
    } );
    #2041685
    Hilton

    I was actually using the correct function but I wrote the wrong one here

    add_filter( 'generate_footer_meta_post_types', function( $types ) {
        $types[] = 'videos';
    
        return $types;
    } );
    #2041722
    Ying
    Staff
    Customer Support

    Then it should work.

    Can you try clear cache and disable cache plugin?

    #2041724
    Hilton

    I disabled cache, but it is not working.

    #2041727
    Hilton

    I don’t know if you noticed the function I put here, which created the CPT. Maybe looking at it, especially at the end, you’ll know why the proposed solution isn’t working.

    #2041855
    Ying
    Staff
    Customer Support

    So it’s working now?

    #2041890
    Hilton

    No

    #2041938
    Elvin
    Staff
    Customer Support

    Hi there,

    The slug being added may be incorrect. Can you link us to a sample single post page of the mentioned CPT?

    #2041951
    Hilton

    Hi Elvin,

    Sure. Follow the link to the CPT page

    https://bit.ly/31BVyRx

    Thanks

    #2041965
    Elvin
    Staff
    Customer Support

    Can you share the customizer settings set for single post pages on Appearance > Customize > Layout > Blog?

    To be specific, here are the things to check – https://share.getcloudapp.com/BluD9Xe2

    Are all of them checked?

    I see that you’re using a Header element. Header elements can disable the default location of the entry meta items if you use the template tags.

    Say for example, if you use {{post_author}} on the Header Element, the meta author will be moved from the default to the Header element.

    #2042011
    Hilton

    Hi Elvin,

    They are marked as you can see here https://www.dropbox.com/s/d430ivdra5jqznh/Captura%20de%20Tela%202021-12-08%20%C3%A0s%2003.10.33.png?dl=0

    I think the confusion is that I want to display a custom category and not post categories. Example of custom categories:

    https://bit.ly/3EDqPCd
    https://bit.ly/30601eR

    In this video you can have a better idea of my needs.

    https://bit.ly/3IxAw7N

    Thanks

Viewing 15 posts - 1 through 15 (of 25 total)
  • You must be logged in to reply to this topic.