我试图隐藏所有页面上的页面标题,除了博客卷。
如果我对 style.css 进行以下更改,它将隐藏所有页面上的标题,包括博客卷:
h1 {
Display:none;
font-size: 48px;
margin: 33px 0;
}
和
.entry-title {
Display:none;
font-weight: normal;
margin: 0 0 5px;
}
根据http://codex.wordpress.org/Conditional_Tags#Testing_for_sub-Pages,为了挑出博客卷,我需要使用以下条件:
if ( is_front_page() && is_home() ) {
// Default homepage
} elseif ( is_front_page() ) {
// static homepage
} elseif ( is_home() ) {
// blog page
} else {
//everyting else
}
因此,我将这些条件应用于我的代码,其中更改最初成功地工作,但它根本不起作用。标题会改变大小和形状,但在所有页面上仍然可见。
修改后的代码:
h1 {
if ( is_front_page() && is_home() ) {
Display:none;
font-size: 48px;
margin: 33px 0;
} elseif ( is_front_page() ) {
Display:none;
font-size: 48px;
margin: 33px 0;
} elseif ( is_home() ) {
font-size: 48px;
margin: 33px 0;
} else {
Display:none;
font-size: 48px;
margin: 33px 0;
}
}
和 ..
.entry-title {
if ( is_front_page() && is_home() ) {
Display:none;
font-weight: normal;
margin: 0 0 5px;
} elseif ( is_front_page() ) {
Display:none;
font-weight: normal;
margin: 0 0 5px;
} elseif ( is_home() ) {
font-weight: normal;
margin: 0 0 5px;
} else {
Display:none;
font-weight: normal;
margin: 0 0 5px;
}
}
我不能Display:none;
在条件语句或其他东西中使用吗?