this is the first time that I write here and my English is not very good, I will try to explain as best as possible.

I want to activate some html text if in the result page, the results, has a particular tag.

For example: i have pages with the "locations" tag.

If I do a search, I wish in the search results, appears html code if the tag of the page reference is "locations". if the tags of the page is different, it should not appear nothing.

I'm looking for in the conditional tags, but I can not find anything like that.

I could express myself well?


  • Yes, your question is clear! – jdm2112 Jul 31 '15 at 17:04

This is completely untested but I believe you would want something along these lines:

if( $loop->have_posts() ):
  while ( $loop->have_posts() ): 
          // Do stuff for results
    echo '<h2>' . the_title() . '</h2>';

    // Check for tag
    if(has_tag($tag) { output HTML if true }

  echo "No Results!";

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.