How to get Post tags?

Discussion in 'WordPress' started by greatlogix, Jun 18, 2010.

  1. #1
    How can I get post tags in wordpress. I found this method the_tags('Tags: ', ', ', '');
    but it shows all tags as links. I just need keywords or tags string. How to...?

    Any help...?
     
    greatlogix, Jun 18, 2010 IP
  2. bvraghav

    bvraghav Member

    Messages:
    123
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    33
    #2
    you can use the function get_the_tags()
    look in wp codex at
    http://codex.wordpress.org/Function_Reference/get_the_tags

    and use it similar to this:
    <?php
    
    $my_prefix = "Tags: ";
    $my_tag_separator = " "; // you can change it to whatever separator you want
    						 // e.g. " &middot; " or " <span class="pad-2-em">&nbsp;</span> "
    						 // or whatever
    						 
    $my_post_tags = get_the_tags();
    if ( $my_post_tags) {
    	$tags_output = "";
    	foreach( $my_post_tags as $tag ) {
    		$tags_output .= ( !$tags_output ) ? $my_prefix . $tag : $my_tag_separator . $tag;
    	}
    }
    
    echo $tags_output;
    
    ?>
    Code (markup):
     
    bvraghav, Jun 19, 2010 IP
    greatlogix likes this.
  3. greatlogix

    greatlogix Active Member

    Messages:
    664
    Likes Received:
    13
    Best Answers:
    1
    Trophy Points:
    85
    #3
    Thanks bvraghav for your great help. Rep added.
     
    greatlogix, Jun 20, 2010 IP