How to Hide Title for Selective WordPress Posts and Pages
In our post about how to hide widget titles, we had an interesting comment that presented a solution to hide title on selective single post and pages. We thought that it might be useful for some people. In this article, we will show you how to hide title for selective WordPress post and pages. We will also show you how to hide title of all WordPress posts and/or pages.
Hide Titles for Selective Posts and Pages
Do you want to hide titles for selective posts and pages without editing a single line of code? Then all you need to do is install and activate the Hide Title plugin for WordPress. After activation, go to the edit screen for the specific post and page. You can do this by simply clicking on the Posts or Pages menu in your WordPress admin and clicking on the item that you want to edit. On the edit screen, you will see a Hide Title meta box like this:
All you need to do is check this box and click on update or publish post button. That’s it. Now this plugin will hide the title on singular page views. What that means is that it will still show the title on your homepage or other archive pages, but not on the single page views. Open the post in the single post view to test the result to make sure that everything looks right.
This solution can be pretty handy if you are creating a simple landing page and you don’t want to show the title.
Hide Titles for All WordPress Posts and Pages
We can’t think of a reason why someone would do this, but lets look at how to hide the titles for all WordPress post and pages for the sake of learning. If for some reason, you want to hide title for all posts and pages on single pages, then you can achieve this by editing your theme. There are few ways of doing this.
The easiest solution would be add this code to your WordPress theme’s functions.php
file.
function wpb_hidetitle_class($classes) { if ( is_single() || is_page() ) : $classes[] = 'hidetitle'; return $classes; endif; return $classes; } add_filter('post_class', 'wpb_hidetitle_class');
This filter simply adds an extra class .hidetitle
to the post_class()
function only when a single post or page is displayed. However, this filter will only work if your WordPress theme has support for the post class. If you want to do this for posts only and not pages, then just get rid of the part || is_page()
.
After adding this function, you need to add this css rule into you theme’s stylesheet.
.hidetitle .entry-title { display:none; }
In the above CSS we have used display
css property to hide the post and page title. However this CSS rule will only work if your WordPress theme uses entry-title in the post or page title. To find out which CSS class your theme uses for post titles, simply open your post in Google Chrome or Mozilla Firefox and take your mouse over to post title. Right click and select Inspect Element. Your browser will split up and you will see page source highlighting the source code for post title where you can see the CSS class used by your theme.
Lets assume that your theme uses article-title
as CSS class for post titles. Simply change the CSS like this:
.hidetitle .article-title { display:none; }
The reason why we say that the above solution is the easiest one is because it will work for child themes of popular theme frameworks like Genesis and others. It will also work just fine for standalone WordPress themes.
Now both of the solutions that we have mentioned above will hide the title, but they are still loading the titles. So in other words, they are hiding it but not removing it. If you are a theme designer or someone who wants to remove the post or page title from your template, then you need to remove the_title code from appropriate theme files.
If you only want to do this for single post views, then you will likely find this code located in your single.php file. However, if you want to do this for through out the site, then you will need to edit files like index.php, archive.php, single.php, and any other file that contains a loop basically. It will require trial and error if you are new to this.
If you are working with one of the theme frameworks, then you would want to stick with the plugin solution or the post_class solution that we showed you.
We hope that this article helped you hide the title for specific WordPress posts and pages. What possible use cases can you see where you would want to hide post or page titles in single views? Let us know by leaving a comment below.