0

我试图隐藏所有页面上的页面标题,除了博客卷。

如果我对 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;在条件语句或其他东西中使用吗?

4

1 回答 1

2

据我了解,您只需要从博客页面中删除标题。使用 css 执行此操作的最简单方法是

.blog .entry-title{display:none}

其中 .blog 是您的博客页面正文的类名。(您可以通过检查元素来获取主体类名称。)

于 2014-06-04T15:20:36.457 回答