• Resolved Víctor Enrich

    (@victorenrich)


    Hi everybody
    My question.
    Developing my wordpress site http://www.victorenrich.com

    I want to get the description of a tag, but not in a tag page, but in the post page.
    To be more precise.
    I have created some post template. On the top right, I have a the_tags function that returns me the tags of the current post, in an unordered list, under a css class called <h2 class=”post_title”> which is black and bold.
    here’s the code

    <h2 class=”post_title”><?php the_tags(‘

    • ‘,’
    • ‘,’

    ‘); ?></h2>

    What I would like is that not only returns the tag name but, above each tag name, returns also the tag description, and, if possible under a css class called <h2 class=”secton_title”>
    which I have it defined as light grey, bold

    I give you an example.
    tag name: 2009, tag description: year
    tag name; barcelona, tag description: location

    should return

    YEAR
    2009
    LOCATION
    BARCELONA

    That’s it…
    I would really appreciate your help.
    My kindest regards to all and have a nice sunday!!

    V

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Víctor Enrich

    (@victorenrich)

    Hi. Thank you for your answer.

    I’ve been trying to “play” with get_the_tags and I almost almost get what I want.

    the code I have now is

    <?php
    			$posttags = get_the_tags();
    			if ($posttags) {
     				 foreach($posttags as $tag) {
     				 	echo $tag->description . '<h2 class="section_title"><ul><li>','</li><li>','</li></ul></h2>';
        				echo $tag->name .  '<h2 class="post_title"><ul><li>','</li><li>','</li></ul></h2>';
     					 }
    				}
    				?>

    this displays me the tag description on the top of each tag.
    But I have 2 little problems.

    1.- unlike the_tags the tags displayed don’t link to the tag page…so, how can I make them “behave” as the_tags, and link me to the specific tag page

    2.- I don’t know how to give a css style to the echo results. You can see in the code aboe that I have introduced some classes such as <h2 class=”section_title”> but it doesn’t take them.
    So, is there a way to do so?

    Thank you very much again.

    V

    Thread Starter Víctor Enrich

    (@victorenrich)

    solved

    <?php
    			$posttags = get_the_tags();
    			if ($posttags) {
     				 foreach($posttags as $tag) {
                        echo $tag->description . '<h2 class="post_title">';
        				echo '<a href="http://www.mysite.com/archives/tag/'.$tag->slug.'" rel="tag">'.$tag->name.'<h1 class="section_title"></a></p>';
    
     					 }
    				}
    				?>

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘tag and tag description’ is closed to new replies.