【发布时间】:2014-06-04 15:06:05
【问题描述】:
我正在尝试隐藏所有页面上的页面标题,博客卷除外。
如果我对 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,为了挑出Blog Roll,我需要使用以下条件:
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; 吗?
【问题讨论】:
-
Wordpress 是否声明您需要将 PHP 脚本粘贴到 CSS 中?
-
等等,这些是 PHP 脚本吗?嘘!回到绘图板。谢谢。
-
我对 CSS、PHP、HTML 的了解如此之少,我看到代码对网站的外观进行了某种更改,这就是为什么我认为我在正确的轨道上。
标签: css wordpress hide title codex