Basic PHP help needed

Discussion in 'PHP' started by animelover19, Dec 6, 2008.

  1. #1
    Hi. I am using wordpress 2.6.
    I have a couple of conditions in stating which content is displayed depending on what article the user is. I have no PHP knowledge.
    Below is the code:

    
    <?php
    if ( is_single('179') ) {
    } elseif (is_single('254')) {
    } elseif (is_single('130')) {
    } elseif (is_single('95')) {
    } elseif (is_single('35')) {
    } elseif (is_single('27')) {
    } elseif (is_single('419')) {
    } elseif (is_single('226')) {
    } elseif (is_single('381')) {
    } elseif (is_single('349')) {
    } elseif (is_front_page()) {
    } elseif (is_single('254')) {
    } else {
    include(TEMPLATEPATH . '/file1.php');
    }
    ?>
    
    Code (markup):
    There must be some way I can clean the above code so that only one is_single statement remains. I tried but couldn't get it to work. If somebody can fix this, it would be great. Thanks.
     
    animelover19, Dec 6, 2008 IP
  2. lfhost

    lfhost Peon

    Messages:
    232
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    
    if (is_front_page()) {
    } elseif (is_single(array(254,179,130,95,35,27,419,226,381,381,349))) {
    } else {
    include(TEMPLATEPATH . '/file1.php');
    }
    
    Code (markup):
    Or you could do the is_single based on the _GET of the id of the post and then do a test on the ID if valid.
     
    lfhost, Dec 6, 2008 IP
  3. animelover19

    animelover19 Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Yup. That worked! Thanks a lot! :)

    But, as I stated earlier, I dont know php so I am not sure what you said about the get and such...
     
    animelover19, Dec 6, 2008 IP