WordPress.org

Ready to get started?Download WordPress

Forums

How to print the current post tags on the screen (4 posts)

  1. adrianTNT
    Member
    Posted 6 years ago #

    Hello, can someone tell me how to print the current post tags on the screen? It returns the word "array" if I use this:

    <?php echo get_tags('orderby=oject_id');?>"
    or this
    <?php echo get_tags();?>"

    What is correct code?
    Thank you.

  2. moshu
    Member
    Posted 6 years ago #

  3. adrianTNT
    Member
    Posted 6 years ago #

    I got it to work by this:

    <?php $posttags = get_the_tags($post->ID);
    	$page_leywords = '';
    	if ($posttags) {
    		foreach($posttags as $tag) {
    			$page_keywords .= $tag->name.',';
    		}
    	$page_keywords = substr($page_keywords, 0, -1);
    	}
    ?>

    Thank you.

  4. Samuel Wood (Otto)
    Tech Ninja
    Posted 6 years ago #

    So, you wanted the tags in a list but without the links, eh? Okay.

    Here's a simpler way:

    $posttags = get_the_tags();
    foreach($posttags as $tag) { $keywords[] = $tag->name; }
    $page_keywords = implode(',',$keywords);

Topic Closed

This topic has been closed to new replies.

About this Topic