0

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?

Thanks

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

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

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

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

  endwhile;
else:
  echo "No Results!";
endif; 

?>

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.