$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>search - Related Tags Concept|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

search - Related Tags Concept

matteradmin6PV0评论

On search results pages I would like to show a tag list collected from other posts that are listed for the seach result.

// same tag should not be listed twice

And for the taxonomy pages again; tags of other post that are listed for the current tag.

I tried some experiments with get_the_tags(array(post ids)) but couldn't make it work.

Thank you,

On search results pages I would like to show a tag list collected from other posts that are listed for the seach result.

// same tag should not be listed twice

And for the taxonomy pages again; tags of other post that are listed for the current tag.

I tried some experiments with get_the_tags(array(post ids)) but couldn't make it work.

Thank you,

Share Improve this question asked Apr 8, 2017 at 7:38 boorockboorock 618 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

You can use simple solution below. You need to use this function in the loop. You can collect tags/categories in an array or show tags/categories under the posts.

$terms = get_the_terms( get_the_ID(), 'category' );
  if ( $terms && ! is_wp_error( $terms ) ) : 
   $catlinks = array();
    foreach ( $terms as $term ) {
      $catlinks[] = $term->name;
    }

$catso = join( ", ", $catlinks );
?>

<p class="list-of-cats">
    <?php printf( esc_html__( 'Categories: <span>%s</span>', 'textdomain' ), esc_html( $catso ) ); ?>
</p>

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far