WordPress.org

Ready to get started?Download WordPress

Forums

If has BOTH tags (3 posts)

  1. salromano
    Member
    Posted 3 years ago #

    I'm trying something new with my blog to indiciate whether or not a news post has screenshots or video attached. We always add the tag Clips to video posts and Screenshots to screenshot posts, so I'm running this in our code:

    <?php if ( has_tag('Screenshots') ) { ?><img src="http://image1.jpg"> <?php } elseif( has_tag('Clips') ) { ?><img src="http://image2.jpg"> <?php } else { ?> <?php } ?>

    However, some posts have BOTH video and screenshots. Is there any way I'd be able to include something like:

    if ( has_tag('Clips+Screenshots') )

    So that image3 would only show if the post has BOTH tags attached?

  2. alchymyth
    Forum Moderator
    Posted 3 years ago #

    php logical operators http://php.net/manual/en/language.operators.logical.php

    example:

    if ( has_tag('Clips') && has_tag('Screenshots') )
  3. salromano
    Member
    Posted 3 years ago #

    Worked like a charm. Thanks, Alchymtyhh!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags