简体   繁体   中英

WordPress get tags for Custom Post Type

Trying to get the tags for a custom post type called public-blob but the code is only pulling in the tags for a single blog post not all the public-blog cpt.

code is:

$posttags = get_the_tag_list();
if ($posttags) {
  foreach($posttags as $tag) {

    echo '<a href="' . get_tag_link( $tag->term_id ) .'">' . $tag->name . '</a>'; 
  }
}

any help will be great.

You should use the function get_the_term_list() this function is like get_the_tag_list() but let you set your taxonomy.

Btw the function get_the_tag_list() and get_the_term_list() not return you an array you should set the before, separator, and after in the function.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM