Support » Plugins » Hacks » Tags styling problem!

  • Resolved PavilionVI

    (@pavilionvi)


    Hello guys;

    I’m working on a custom tags page and I have one little problem that I couldn’t figure out!

    I put this code in the theme’s functions.php

    function get_tgrid() {
    $wpbtags =  get_tags();
    $output .= '<div class="grid"><div class="tagslist"><ul class="tagsgrid">';
    foreach ($wpbtags as $tag) {
    	$output .= '<li class="item"><a href="'. get_tag_link($tag->term_id) .'" style="background-image: url("/wp-content/uploads/tags/' . $tag->slug . '.jpg")"><span class="item-name"><span class="count">'. $tag->count .'</span><span class="item-name">'. $tag->name . '</span></span></a></li>';
    	}
    $output .= '</ul></div></div>';
    return $output;
    }

    The problem is instead of giving the intended output which is like:
    <a href="http://myblog.com/tag/example/" style="background-image: url("/wp-content/uploads/tags/example.jpg")"><span class="item-name"><span class="count">1</span><span class="item-name">EXAMPLE</span></span></a>

    it gives me this:
    <a href="http://myblog.com/tag/example/" style="background-image: url(" wp-content="" uploads="" tags="" example.jpg")"=""><span class="item-name"><span class="count">1</span><span class="item-name">EXAMPLE</span></span></a>

    I’m a php newbie and I’d appreciate a little help!
    Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You are using singe single quotation marks inside single quotation marks. This won’t work.

    Try this instead:

    $output .= '<li class="item"><a href="'. get_tag_link($tag->term_id) .'" style="background-image: url(\'/wp-content/uploads/tags/' . $tag->slug . '.jpg\')"><span class="item-name"><span class="count">'. $tag->count .'</span><span class="item-name">'. $tag->name . '</span></span></a></li>';

    I’d give you a hug if I could!
    Thanks a lot julian, it worked like a charme!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Tags styling problem!’ is closed to new replies.