1

I use this code and it works:

    if ( in_category( 'videos' )) {
    echo '<span class="corner-tag blue">something else</span>';
}

But in this code how can I add an href link?

I try something like this but it didn't work:

if ( in_category( 'videos' )) {
        echo '<span class="corner-tag blue" a href="http://google.com">something else</span></a>';
    }

Thanks.

danday74
  • 52,471
  • 49
  • 232
  • 283
I.Alex
  • 63
  • 1
  • 10

1 Answers1

2

you need two different tags, one inside the other. for example, you have to open the <a> tag and close it inside your <span> tag, or vice a versa:

<span><a></a></span>:

echo '<span class="corner-tag blue"><a href="http://google.com">something else</a></span>';

<a><span></span></a>:

echo '<a href="http://google.com"><span class="corner-tag blue">something else</span></a>';

<a href="http://google.com"><span class="corner-tag blue">something else</span></a>

<br/>

<span class="corner-tag blue"><a href="http://google.com">something else</a></span>
Jeff Puckett
  • 37,464
  • 17
  • 118
  • 167
  • Thanks, I forgot that. It worked but we only had to change something about him: echo 'something else'; – I.Alex Apr 26 '16 at 02:37
  • I will accept your answer : You can accept an answer in 9 minutes – I.Alex Apr 26 '16 at 02:38
  • Jeff, when I press click opens a small window named: [about:blank] of google chrome and it didin't load google. – I.Alex Apr 26 '16 at 02:40
  • well that's very strange. I have posted a working snippet of the html for example, and you can see it works either way – Jeff Puckett Apr 26 '16 at 02:43
  • It works now, was my code fault, i have one small question , how can i make to open in new window, it works like html with target = blank ? – I.Alex Apr 26 '16 at 02:52
  • @I.Alex, yes [see this](http://stackoverflow.com/questions/4964130/target-blank-vs-target-new) should be helpful. also, this is really more of a [follow-up question](http://meta.stackexchange.com/questions/19457/where-should-i-post-follow-up-questions), try sticking to [one question per question](http://meta.stackoverflow.com/questions/308796/is-there-a-way-of-grouping-a-bunch-of-related-question-you-want-to-ask-so-that-a#308834) – Jeff Puckett Apr 26 '16 at 16:26