WordPress.org

Plugin Directory

SubHeading

Adds the ability to easily add and display a sub title/heading on any public post type.

How do I enable subheadings on posts and custom post types?

By default subheadings are only enabled for pages, you can enable them for posts or any public custom post type via the Settings > Reading page.

Just check the box that says Enable on Posts. or the required post type.

What custom field name does it use?

The field name used is _subheading, the underscore prefix prevents it from being displayed in the list of custom fields.

How can I append the subheading to my RSS feed?

Check the RSS option on the settings page Plugins > SubHeading > Append to RSS feeds.

What if I want to include shortcodes in my subheading?

Check the apply shortcode filters option on the settings page Plugins > SubHeading > Apply shortcode filters.

This will apply any existing shortcode filters to the subheading value you have set.

How can I prevent the subheading input moving to the top of the edit page?

Some plugins will hide the element containing the post title, which is this element that the subheading input is appended to.

You can prevent the repositioning of the input via the options page.

What are the `Before` and `After` inputs used for?

If you are using the option to automatically wrap the subheading content, you can include custom content before and after the subheading is displayed.

For example, setting Before to <h3> and after to </h3> will wrap the subheading in a h3 tag.

How can I stop subheadings appearing in places I don't want them to?

Using the "Automatically display subheadings before post content." setting will prepend any subheading value before outputting any post content.

The output can be customised slightly using the "Before" and "After" fields, however if you prefer more customisation and control it is probably best to disable this setting and edit the output within your theme templates.

To display subheadings, place <?php if (function_exists('the_subheading')) { the_subheading('<p>', '</p>'); } ?> in your template files where you want the subheading to appear.

Why do tags some tags disappear from my subheadings?

By default the plugin uses the default list of allowed tags, which can result in certain tags such as <br /> and <p> being removed from subheadings or settings.

This can be resolved by adding valid tags to the allowed list using either the subheading_tags or subheading_settings_tags filters.

If, for example, you wanted to enable the <br /> tag in subheadings, include the following function to your theme functions.php file.

add_filter( 'subheading_tags', function( $tags ) {
    $tags['br'] = array();
    return $tags;
} );

Note here that the array key 'br' is the tag name and the values array should be a list of valid attributes for that tag, for example $tags['span'] = array('class' => array(), 'id' => array());.

The list of default allowed tags for both subheadings and settings (before and after) is as follows:

$allowedtags = array(
    'a' => array(
        'href' => array(),
        'title' => array()),
    'abbr' => array(
        'title' => array()),
    'acronym' => array(
        'title' => array()),
    'b' => array(),
    'blockquote' => array(
        'cite' => array ()),
    'cite' => array(),
    'code' => array(),
    'del' => array(
        'datetime' => array()),
    'em' => array(),
    'i' => array(),
    'q' => array(
        'cite' => array()),
    'strike' => array(),
    'strong' => array(),
);

The settings validation additioanlly allows the following tags.

...
    'h1' => array(
        'class' => array(),
        'id' => array()),
    'h2' => array(
        'class' => array(),
        'id' => array()),
    'h3' => array(
        'class' => array(),
        'id' => array()),
    'h4' => array(
        'class' => array(),
        'id' => array()),
    'h5' => array(
        'class' => array(),
        'id' => array()),
    'h6' => array(
        'class' => array(),
        'id' => array()),
    'p' => array(
        'class' => array(),
        'id' => array()),
...

If you require the use of an additional tags or attributes, they will need to be added using the filters.

How can I limit the length of the subheading?

As of version 1.7.1 you can make use of the 'subheading' filter to manipulate the final output.

For example, limiting the subheading to 5 words can be done by adding the following to your theme functions.php file.

add_filter( 'subheading', function( $value ) {
    return wp_trim_words( $value, 5 );
} );

This example makes use of the wp_trim_words function introduced in WordPress 3.3.

Why do the code snippets / examples from the readme not work?

If you are using older versions of PHP (< 5.3.0), you will not be able to make use of anonymous functions used in some of these examples.

Further information on the use of anonymous functions and WordPress can be read in the [WordPress Codex](http://codex.wordpress.org/Function_Reference/add_filter#Beware WordPress Codex Reference).

Requires: 3.2.1 or higher
Compatible up to: 3.6.1
Last Updated: 2013-8-11
Active Installs: 6,000+

Ratings

4.3 out of 5 stars

Support

1 of 1 support threads in the last two months have been resolved.

Got something to say? Need help?

Compatibility

+
=
Not enough data

1 person says it works.
0 people say it's broken.

100,1,1
100,2,2 100,1,1 100,2,2 100,1,1 100,1,1 100,1,1 100,1,1
100,1,1 100,1,1 100,1,1 100,1,1 100,2,2 100,1,1 100,2,2 100,1,1 100,1,1 100,1,1 100,1,1 100,1,1
100,1,1 100,4,4
100,1,1 100,2,2 100,1,1 100,1,1
100,2,2
0,1,0 50,4,2 100,1,1
0,1,0 100,4,4
100,2,2
100,4,4
100,1,1
75,4,3 0,1,0
50,2,1
100,1,1
100,1,1
100,1,1 100,1,1
100,1,1
50,4,2
100,1,1 67,3,2
100,1,1
0,1,0
100,1,1
100,1,1
100,1,1
0,1,0
100,1,1