如何删除Page Header标题?

Table of Contents

You might ever have a requirement, where you needed to remove Page Header Title. And previously the only option was to hide the same using custom CSS.

您可能会有这样的需求,需要删除Page Header标题。在此之前,唯一的选择是使用自定义CSS隐藏相同的内容。

We are providing two filters. One to remove the Page Header Title and another one to add the Page Title in the Content Area.

我们提供两个过滤器。一个用于删除Page Header标题,另一个用于在内容区域添加Page Header标题。

Astra Page Header Title

Let’s dive into both the cases and see the filter on how it will work –

让我们深入研究这两种情况,看看过滤器是如何工作的

Case 1: #

How to remove Page Header Title which appears on top of the image. Here, you can remove the Page Header Title on all single pages, archive pages, and posts. Alternatively, you can remove Page Header Title only from single pages (the title will still be visible on archive pages and posts), from all pages (but not posts), or only from your Home page.

如何删除出现在图像顶部的Page Header标题。在这里,您可以删除所有单页、归档页和帖子的Page Header标题。或者,你可以只从单个页面删除Page Header标题(标题仍然在存档页面和帖子上可见),从所有页面(但不是帖子),或只从你的主页。

Solution 1: You will need to add the following filter, to remove the Page Header Title on all single pages, archive pages, and posts:
解决方案1:你将需要添加以下过滤器,以删除所有单一页面,归档页面和帖子的Page Header标题:

add_filter( 'astra_advanced_header_title', 'remove_page_header_title' );
function remove_page_header_title() {
  return;
}

Solution 2: You will need to add the following filter, to remove the Page Header Title only from single pages:

add_filter( 'astra_advanced_header_title', 'page_header_title_disable' ); 
function page_header_title_disable( $title ) { 
  if ( is_page() ) {
    $title = false;
  }
  return $title;
};

Solution 3: You will need to add the following filter, to remove the Page Header Title from all pages but leave it on all posts:

解决方案3:你需要添加以下过滤器,删除所有页面的页眉标题,但留下它在所有的帖子:

add_filter( 'astra_advanced_header_title', 'page_header_title_disable' );
function page_header_title_disable( $title ) {
if ( is_singular( 'page' ) || is_archive() ) {
$title = false;
}
return $title;
}

Solution 4: You will need to add the following filter, to remove the Page Header Title only from the Home page:

解决方案4:您将需要添加以下过滤器,以删除页眉标题仅从主页:

add_filter( 'astra_advanced_header_title', 'page_header_title_disable' );

function page_header_title_disable( $title ) {
if ( is_front_page() || is_home() ) {
$title = false;
}
return $title;
};

Note #

To use one of the above-mentioned codes, just copy, and paste it in the child theme’s functions.php file.

要使用上述代码之一,只需复制并粘贴到子主题的functions.php文件中。

Case 2: #

After removing the Page Header from the Top Banner, we will need to add the title in the below content area.

从顶部横幅删除页眉后,我们需要在下面的内容区域添加标题。

Solution: Let’s see the filter you will need to add the title to the content area –

解决方案:让我们看看将标题添加到内容区域所需的过滤器

add_filter( 'astra_the_title_enabled', 'display_page_title', 999 );
function display_page_title() {
  return true;
}

Note #

Paste the above code in the child theme’s functions.php file.

This is how you can remove the Page Header Title and add the Title in the content section.

将上面的代码粘贴到子主题的functions.php文件中。

这就是如何删除页眉标题和添加内容部分的标题。

Astra Page Header Content Section

Powered by BetterDocs

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

Scroll to Top