
How to remove the title from a certain content type
Sometimes you just want to get rid of that pesky title in your Drupal installation. Perhaps you're displaying it via Views for some reason, or you just want to be a bit annoying... what do I know. If you want to remove the title - perhaps depending on what kind of content type (node type) you are displaying - there are many ways to do this.
I'm going to show you some of the ways you can do this.
Drupal 7
In Drupal 7 the title is part of the content so you can easily remove it or place it somewhere else as you can in Drupal 8 (we're coming to that shortly). Therefore you need to remove through code - either in your theme or by the help of a module.
By code
function mythemename_preprocess_page(&$vars, $hook) {
if(isset($vars['node']) && $vars['node']->type == 'article') {
$vars['title'] = FALSE;
}
}
Change the mythemename to what your theme is called. If you're using a theme called mothertrucker then the line would read
function mothertrucker_preprocess_page(&$vars, $hook) {
Note that if your content type is called something with a hyphen then you must change this to underscore.
If the content type is called funny-image then the line would read
if(isset($vars['node']) && $vars['node']->type == 'funny_image') {
Add new comment