0

I have this is my functions.php file to create tags only for custom post type called 'image-gallery':

register_taxonomy(
  'image-gallery_tags',
  'image-gallery',
  array(
    'label'        => __( 'Image Tags' ),
    'rewrite'      => false,
    'hierarchical' => false,
    'capabilities' => array( 'edit_terms' => 'manage_categories' )
  )
);

But I can't get the list of tags to show in the post loop on the front end. I have tried get_the_tags(); and get_the_tag_list(); but they will only show tags which are generic to all posts, not the tags for the custom post type. Any help?

1 Answer 1

2

get_the_tags() is a shortcut function to get the terms from the post_tags taxonomy.

What you have done is make a new and different taxonomy. And you will need to use get_the_terms() to get your required data.

E.g.

$terms = get_the_terms($post, 'image-gallery_tags'); 

https://developer.wordpress.org/reference/functions/get_the_terms/

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.