How to combine these two php codes into one

Discussion in 'PHP' started by Mazakustrum, Aug 4, 2014.

  1. #1
    This a wrong script and basically I'm trying to combine them into one using the && thingy but I can't quite make it work.

    <?php
    
    if (is_archive()) {
    <meta name="robots" content="noindex, nofollow" />;
    }
    
    elseif (is_category()) {
    <meta name="robots" content="noindex, nofollow" />;
    }
    ?>
    Code (markup):
     
    Solved! View solution.
    Mazakustrum, Aug 4, 2014 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    Have you tried the || thingy?
     
    nico_swd, Aug 4, 2014 IP
  3. Mazakustrum

    Mazakustrum Peon

    Messages:
    18
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    3
    #3
    No. How do I do that? Do I just do

    <?php
    if (is_archive()) || (is_category()) {
    <meta name="robots" content="noindex, nofollow" />;
    }
    ?>
    
    Code (markup):
     
    Mazakustrum, Aug 4, 2014 IP
  4. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #4
    Remove one closing parentheses before the || thingy, and the opening parentheses after the thingy.
     
    nico_swd, Aug 4, 2014 IP
  5. #5
    
    if (is_archive() && is_category())
    
    Code (markup):
    The above will only be true if both conditions are met, while
    
    if (is_archive() || is_category())
    
    Code (markup):
    will be true if any of the conditions are met
     
    PoPSiCLe, Aug 4, 2014 IP
  6. Mazakustrum

    Mazakustrum Peon

    Messages:
    18
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    3
    #6
    Holy shit I just leveled up
     
    Mazakustrum, Aug 4, 2014 IP
    PoPSiCLe likes this.