0

I have created a new post type named "Project". And I registered 1 taxonomy "Tags" in it as follows:

https://pastecode.xyz/view/844258b1

I entered the tags into 1 article in post type "Project".

If you want to enter an article, it will display all the tags in that article.

Can someone help me. Thank you!

  • Please include the code in your post and highlight it. What values does this link have as soon as it goes 404? – leymannx Mar 29 at 18:52
0

You have to be careful when creating a custom post type with taxonomy and the same namespace "tags", since tags are already registered by WordPress default for the post type posts. Maybe the renaming of the taxonomy to project-tags or something else would make sense. Otherwise the taxonomy will be mixed up by WordPress.

To show all tags you can use PHP:

the_tags('<ul class="taglist"><li>', '</li><li>', '</li></ul>');

Note: This function must be within the loop (archive.php or single.php).

0

Check out get_the_tag_list() to retrieve all the tags:

https://codex.wordpress.org/Function_Reference/get_the_tag_list

Examples:

$separate_meta = __( ', ' );
echo $tags_list = get_the_tag_list( '', $separate_meta );

OR:

<?php
 $tags = get_tags();
 if ($tags) {?>
  <ul class="tags">
  <?php
    foreach ($tags as $tag) {
    echo '<li><a href="' . get_tag_link( $tag->term_id ) . '" 
    title="' . sprintf( __( "View all posts in %s" ), $tag->name ) . '" ' . '>' . $tag->name.'</a></li>';
  }
  ?>
  </ul>
<?php }?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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