开发者

Creating multiple if else statements

Need help from a developer. I'm using an if else statement in my wordpress theme to render two different kinds of single post templates. Now I have to add another template. The present code is:

$post = $wp_query->post;
    if ( in_category('1204') ) {
     开发者_如何学编程   include(TEMPLATEPATH . '/1204-article.php');
        }

    else {
        include(TEMPLATEPATH . '/regular-article.php');
        }

I want to include/append an additional statement that if in_category('345') then include 345-article.php else include regular-article.php

Thanks.


Just add another else if, i.e.:

$post = $wp_query->post;
if ( in_category('1204') ) 
{
    include(TEMPLATEPATH . '/1204-article.php');
}
else if ( in_category('345') ) 
{
      include (TEMPLATEPATH . '/345-article.php');
}
else 
{
    include(TEMPLATEPATH . '/regular-article.php');
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜