• Resolved hilj

    (@hilj)


    This works like it should:

    <?php
    	if (is_category('18'))
    		{
    		include(TEMPLATEPATH . '/blog.php');
    		}
    	else { ?>
            ...rest of the page
    <?php }

    This doesn’t:

    <?php
    	if (is_category('18'))
    		{
    		include(TEMPLATEPATH . '/blog.php');
    		}
            if (is_category('29'))
    		{
    		include(TEMPLATEPATH . '/pagelinks.php');
    		}
    	else { ?>
            ...rest of the page
    <?php }

    How should I ad the second if statement? This is just something really simple, I’m just learning php.

    I’m using WP as CMS, goal is to generate blog and links from their own pages.

    All help is very much appreciated!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hello.

    <?php
    	if (is_category('18'))
    		{
    		include(TEMPLATEPATH . '/blog.php');
    		}
            elseif (is_category('29'))
    		{
    		include(TEMPLATEPATH . '/pagelinks.php');
    		}
    	else { ?>

    Note the “elseif” in your second condition…

    S.

    Thread Starter hilj

    (@hilj)

    Okay, i see. I assume same goes for third and more statements.

    Thank you for you super fast reply!

    Yes, for any other condition following the first “if”, you should use “elseif”.

    S.

    Is it possible to have multiple categories in one statement?

    Something like:

    <?php
    	if (is_category('18, 19, 20'))
    		{
    		include(TEMPLATEPATH . '/blog.php');
    		}
            elseif (is_category('27, 28, 29'))
    		{
    		include(TEMPLATEPATH . '/pagelinks.php');
    		}
    	else { ?>

    Thank you.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Two if statements in a row?’ is closed to new replies.