How to hide the title of entries and pages in the theme Astra

astra theme templates

One of the characteristics that every current WordPress theme must have is “dispensability”, that is, the ability for you, as the owner of your content, to decide what is shown and what is not shown in each situation, page or entry of your website.

With this goal in mind, there are more and more themes and plugins that offer the possibility of hiding the titles of posts and pages, because on many occasions, especially when the first thing in the content is an image or video, it is unnecessary to show the title of the page.

Of course, the Astra theme meets this feature of “dispensability”, and does it without having to purchase the paid version.

How to hide the title of an entry or page with the Astra theme

If you just want to hide the title of an entry or page with Astra you don’t have to write a single line of code.

The Astra theme adds a number of settings to the WordPress editor from which you can customize, show or hide the different elements of the theme: headers, sidebars, and of course the title.

Just go to the Astra settings section and disable the title.

The title of your post or page will still exist internally, at the code level, but will not be displayed in your content.

In addition, it will be changed from an H1 to the title of the page, and H1 can be assigned to another element of the content.

How to hide the titles of all entries and pages with the Astra theme

Now, have you decided that the titles of your entries and pages will never be shown?

It would be pretty awkward to have to check that box in all the entries and pages, wouldn’t it?

No, you can disable the titles globally, for all posts, pages and other types of content, with a simple code, which as always we will add to the functions.php file of the active child theme:

/* Deactivate/hide titles in all kind of contents */ 
function your_prefix_post_title() { 
$post_types = array('page'); 
if ( ! in_array( get_post_type(), $post_types ) ) { return; } // Deactivate featured image 
add_filter( 'astra_the_title_enabled', '__return_false' ); 
}
add_action( 'wp', 'your_prefix_post_title' );Code language: PHP (php)

In this example we have disabled it for the pages. For other content types it replaces or adds the content type to the array.

Read this post in Spanish: Cómo ocultar el título de entradas y páginas en el tema Astra #SemanaAstra

How useful was this post?

Click on a smiley to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

As you found this post useful...

Follow us on social media!

About The Author

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top
Skip to content