WordPress: Remove link in the_tags

How do I remove the link generated by the_tags?

This is what I use today: <?php the_tags( '', '', '' ); ?>

Read More

That results in the tags assigned to the post. But I want to remove the link. Any idea?

Related posts

Leave a Reply

3 comments

  1. Get the tag list, and then strip the tags.

    <?php
    if (is_single()) { the_post(); rewind_posts();
      $articletags = strip_tags(get_the_tag_list('',', ',''));
      echo $articletags;
    
  2. This is probably a better way of doing so.

    Filter the links, by stripping/removing all HTML tags from all post tag links.

    add_filter('term_links-post_tag', function($links) {
        return array_map('wp_strip_all_tags', $links);
    });
    

    Then call the_tags, get_the_tag_list or get_the_terms_list to retrieve the post tags.

    Note: this removes the links from post tags everywhere when called from one of the above functions, so also in your feed.