Subtitles for articles easily add headings in WordPress

In this post I would like to introduce the Subtitles plugin, with which you can easily add subtitles for article headings in WordPress. The subtitles are possible for articles and static pages as well as custom post types.

As is so often the case, there are several plugins for subtitles. Subtitles is my personal favorite because the plugin works without code adjustments in the theme and has been reduced to the bare essentials - so it's very plain and simple.

This makes it ideal for beginners because no theme files have to be edited to add template functions to the output of the subtitle. At the same time, there are some hooks and filters for WordPress developers to adapt the plugin.

Subtitles Download

The plugin can be downloaded from Github or the official WordPress plugin directory. It doesn't have a single bad rating and is currently installed on over 9,000 websites.

Add subtitles into your WordPress posts, pages, custom post types, and themes. No coding required. Simply activate subtitles and you're ready.

Creators: Philip Arthur Moore, We Cobble

( 52 )
Last updated: 3 years ago
10,000+ active installations
Compatible up to: 4.8.15

Add subtitles

Subtitles does not have its own options and just inserts a new input field for the subtitle below the normal field for the title.

The field fits seamlessly into the WordPress interface and therefore works almost like a core feature, not as a foreign body.

Output of the subtitle

As already mentioned, the plugin automatically and automatically displays the subtitle in the theme. To do this, the plugin simply hooks into the the_title () function, which usually outputs the title of the article or page in the theme.

The standard themes such as TwentySixteen mostly use the .entry-title and h1 class to display the title on individual article pages .

Without using the plugin, the HTML code of the title usually looks like this or something similar, depending on the theme:

 <h1 class="entry-title"> Überschrift des Beitrags </h1>

The plugin replaces the normal title and also inserts the subtitle. Both titles are enclosed by span elements with their own classes and can thus be adapted to the styling of the theme with a little CSS code.

 <h1 class="entry-title"> <span class="entry-title-primary">Überschrift des Beitrags</span> <span class="entry-subtitle">Ein passender Untertitel</span> </h1>

For the .entry-subtitle class of the subtitle, the plugin adds some CSS code very sparingly.

 span.entry-subtitle { display: block; font-size: 0.53333333333333em; }

display: block causes subtitles to be displayed on a separate line. In addition, the font size for the subtitle is reduced.

The result:

Except for the font size, the subtitle inherits the styling of the title, ie font, color, etc. are exactly the same. With a little CSS code, the styling can of course be adjusted even further.

For example, I think a different color is very good, which visually sets off the subtitle even more clearly (e.g. black title and gray subtitle).

Subtitles are not displayed?

The plugin automatically inserts the subtitles by filtering the normal titles within the WordPress loop. The basic requirement is therefore that the theme used uses the the_title function to display the headings.

No subtitles are displayed outside of the normal content in the WordPress loop. The subtitles are missing in the sidebar, in navigation menus or in footer widgets. There these would also mostly be undesirable.

Add support for Custom Post Types

By default, the plugin adds the input field for the subtitles for posts and static pages. Support for custom post types can be added with just a few lines of code.

 function theme_slug_add_subtitles_support() { add_post_type_support( 'custom-post-type-slug', 'subtitles' ); } add_action( 'init', 'theme_slug_add_subtitles_support' );

At the same time, the plugin can also be removed for the standard post types of the core, if subtitles are only used for posts or static pages.

 function theme_slug_remove_subtitles_support() { remove_post_type_support( 'post', 'subtitles' ); remove_post_type_support( 'page', 'subtitles' ); } add_action( 'init', 'theme_slug_remove_subtitles_support' );

Hooks and filters for theme developers

The plugin provides various filters, hooks and template tags for WordPress developers. With this, for example, the HTML markup of the subtitles can be changed or the display can be restricted to certain pages (e.g. archives, categories).

An overview of the possibilities and code examples can be found on the Github page of Subtitles .