How to Remove Page Header Title?

How to Remove Page Header Title?

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.

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

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.

Solution 1: You will need to add the following filter, to remove the Page Header Title on all single pages, archive pages, and posts:

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:

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:

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.

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.

发表回复

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