PHP If statement always passing first statement -


i'm having problem if statement, sits inside of wordpress loop. first if statement — if ( $caption == "1") — seems work, second seems pass, when $image_title doesn't == strings.

foreach ( $images $attachment_id => $attachment ) {          // $alt = get_post_meta($attachment->id, '_wp_attachment_image_alt', true);         $image_title = $attachment->post_title;         $caption = $attachment->post_excerpt;         $description = $attachment->post_content;          $img_url = get_post_meta( $attachment->id, '_gallery_link_url', true ); //wp gallery custom links url field           if ( $caption == "1") {                   echo '<div class="imagewrapb">';                      if ($image_title == "branding" or "print" or "digital" or"packaging") {                         echo '<h3>'.$image_title.'</h3>';                         echo wp_get_attachment_image( $attachment_id, '' );                         echo '<a href="'.$img_url.'">'.'<div class="hover">'.$description.'</div>'.'</a>';                      var_dump($image_title);                      }                      else if ($image_title == "twitter") {                         echo '<h3>'.$image_title.'</h3>';                         echo wp_get_attachment_image( $attachment_id, '' );                         echo '<div class="twitterfeed"><h2>@v_ix</h2><ul id="twitter_update_list"><li>twitter feed loading</li></ul></div>';                     }                                         else if ($image_title == "facebook") {                         echo '<h3>'.$image_title.'</h3>';                         echo wp_get_attachment_image( $attachment_id, '' );                         echo '<div class="facebookfeed">';                         include 'facebook.php';                         echo '</div>';                     }                      else {                          if ( !empty($img_url) /*img_url exists*/ ){                              echo '<h3>'.$image_title.'</h3>';                              if ( !empty($description) /*description exists*/ ){                                 echo wp_get_attachment_image( $attachment_id, '' );                                 echo '<a href="'.$img_url.'">'.'<div class="hover">'.$description.'</div>'.'</a>';                             }                              else {                                 echo '<a href="'.$img_url.'">';                                 echo wp_get_attachment_image( $attachment_id, '' );                                 echo '</a>';                              }                         }                             else  { /*img_url doesnt exist*/                              echo '<h3>'.$image_title.'</h3>';                              if ( !empty($description) /*description exists*/ ){                                 echo wp_get_attachment_image( $attachment_id, '' );                                 echo '<div class="hover">'.$description.'</div>';                             }                              else {                                 echo wp_get_attachment_image( $attachment_id, '' );                             }                         }                      }                  echo '</div>';           }          else {                     echo '<div class="imagewrap">';                      if ($image_title == "branding" || "print" || "digital" || "packaging") {                         echo '<h3>'.$image_title.'</h3>';                         echo wp_get_attachment_image( $attachment_id, '' );                         echo '<a href="'.$img_url.'">'.'<div class="hover">'.$description.'</div>'.'</a>';                     }                      else if ($image_title == "twitter" ) {                         echo '<h3>'.$image_title.'</h3>';                         echo wp_get_attachment_image( $attachment_id, '' );                         echo '<div class="twitterfeed"><h2>@v_ix</h2><ul id="twitter_update_list"><li>twitter feed loading</li></ul></div>';                     }                                         else if ($image_title == "facebook") {                         echo '<h3>'.$image_title.'</h3>';                         echo wp_get_attachment_image( $attachment_id, '' );                         echo '<div class="facebookfeed">';                         include 'facebook.php';                         echo '</div>';                     }                      else {                          if ( !empty($img_url) /*img_url exists*/ ){                              echo '<h3>'.$image_title.'</h3>';                              if ( !empty($description) /*description exists*/ ){                                 echo wp_get_attachment_image( $attachment_id, '' );                                 echo '<a href="'.$img_url.'">'.'<div class="hover">'.$description.'</div>'.'</a>';                             }                              else {                                 echo '<a href="'.$img_url.'">';                                 echo wp_get_attachment_image( $attachment_id, '' );                                 echo '</a>';                              }                         }                             else  { /*img_url doesnt exist*/                              echo '<h3>'.$image_title.'</h3>';                              if ( !empty($description) /*description exists*/ ){                                 echo wp_get_attachment_image( $attachment_id, '' );                                 echo '<div class="hover">'.$description.'</div>';                             }                              else {                                 echo wp_get_attachment_image( $attachment_id, '' );                             }                         }                      }                  echo '</div>';          }     } 

changing if statement (what believe be?) correct — if (($image_title == "branding")||($image_title == "print")||($image_title == "digital")||($image_title =="packaging")) {— seems not display variables 'branding' etc strings.

if ($image_title == "branding" or "print" or "digital" or "packaging") 

must be:

if ($image_title == 'branding' || $image_title == 'print' || $image_title == 'digital' || $image_title == 'packaging') 

Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -