- This topic has 24 replies, 3 voices, and was last updated 4 years, 5 months ago by
Elvin.
-
AuthorPosts
-
December 7, 2021 at 12:33 pm #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' );December 7, 2021 at 12:39 pm #2041665Ying
StaffCustomer SupportHi Hilton,
Try these snippet to add meta to CPT:
https://docs.generatepress.com/article/generate-footer-meta-post-types/
https://docs.generatepress.com/article/generate_entry_meta_post_types/Let me know if this helps 🙂
December 7, 2021 at 12:57 pm #2041674Hilton
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
December 7, 2021 at 1:06 pm #2041680Ying
StaffCustomer SupportYou are not supposed to change the filter name:
generate_footer_meta_post_types.Can you give it another try?
December 7, 2021 at 1:07 pm #2041681Hilton
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; } );December 7, 2021 at 1:09 pm #2041685Hilton
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; } );December 7, 2021 at 2:06 pm #2041722Ying
StaffCustomer SupportThen it should work.
Can you try clear cache and disable cache plugin?
December 7, 2021 at 2:10 pm #2041724Hilton
I disabled cache, but it is not working.
December 7, 2021 at 2:20 pm #2041727Hilton
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.
December 7, 2021 at 5:27 pm #2041855Ying
StaffCustomer SupportSo it’s working now?
December 7, 2021 at 7:02 pm #2041890Hilton
No
December 7, 2021 at 9:05 pm #2041938Elvin
StaffCustomer SupportHi there,
The slug being added may be incorrect. Can you link us to a sample single post page of the mentioned CPT?
December 7, 2021 at 9:16 pm #2041951Hilton
December 7, 2021 at 9:36 pm #2041965Elvin
StaffCustomer SupportCan 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.December 7, 2021 at 11:21 pm #2042011Hilton
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/30601eRIn this video you can have a better idea of my needs.
Thanks
-
AuthorPosts
- You must be logged in to reply to this topic.