Support » Fixing WordPress » how to override get_the_tags core func in theme func and add spans to it

  • Resolved devric

    (@devric)


    Hi

    With the_tag(), i want to add a <span></span> in front and after EACH tag of the tag list for styling like this :– eg: for tag1 and tag2

    <span class="tag_open"></span>
            <span class="tag">tag1_name </span>
    <span class="tag_close"></span>
    
    <span class="tag_open"></span>
            <span class="tag">tag2_name </span>
    <span class="tag_close"></span>

    I thought about using the :before and :after css but ie6 dont support. So how do i override the function? or how to write a custom foreach loop function to list the tags of the post?

    Thank you

Viewing 2 replies - 1 through 2 (of 2 total)
  • there are two ways:

    either, writing your own function, using:
    get_the_tags()
    http://codex.wordpress.org/Function_Reference/get_the_tags

    or, using the parameters of ‘the_tags()’
    http://codex.wordpress.org/Function_Reference/the_tags

    i.e.

    <?php the_tags('TAGS: <span class="tag_open"></span><span class="tag">','</span><span class="tag_close"></span>
    <span class="tag_open"></span><span class="tag">','</span><span class="tag_close"></span>'); ?>

    which would result in (for instance):

    TAGS: <span class="tag_open"></span><span class="tag"><a href="http://localhost/wordpress/keywords/apples" rel="tag">apples</a></span><span class="tag_close"></span>
    <span class="tag_open"></span><span class="tag"><a href="http://localhost/wordpress/keywords/bananas" rel="tag">bananas</a></span><span class="tag_close"></span>
    <span class="tag_open"></span><span class="tag"><a href="http://localhost/wordpress/keywords/chattels" rel="tag">chattels</a></span><span class="tag_close"></span> 
    
    <span class="tag_open"></span><span class="tag"><a href="http://localhost/wordpress/keywords/cienaga" rel="tag">cienaga</a></span><span class="tag_close"></span>

    (keep in mind that each tag name is actually a link)

    thanks works perfect and simple!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘how to override get_the_tags core func in theme func and add spans to it’ is closed to new replies.