开发者

If else selector ignored?

I want to make two different headers for my WordPress project, so the frontpage will display differently than the rest of the pages. I would do it with an if/else statement, but it seems that the last part of the string is being ignored.

What could trigger this?

The code looks like this and links to two id's in a separate css file. The first statement "top_frontpage" goes through all the pages instead of grapping "top_sub" when on the sub pages.

<?php开发者_如何学C if ( is_front_page ) { echo '<div id="top_frontpage">'; } else { echo '<div id="top_sub">'; }; ?>

Hope you guys can help me out.


is_front_page() is a function.

You need to use

<?php if ( is_front_page() ) 


adding to what @Pekka said - you probably want that is_front_page to either be $is_front_page or is_front_page() because PHP turns unquoted alphanumeric character sequences (such as is_front_page) into literal strings unless they are defined as constants thus your statement is equivalent to

if ('is_front_page') { //this is never going to be false
    //blah
}else{
    //never executed
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜