WP Subtitle

Wordpress Plugin
Download latest - 3.4.1

Developers

husobj
husani

Download Stats

Today 73
Yesterday 119
Last Week 980
All Time 164,563
Banner 772x250

The WP Subtitle plugin allows your pages and posts to contain a subtitle. Also called a sub-heading, this this short line of text is meant to appear beneath a post's (or page's) title, but can be inserted in your template wherever you choose.

The subtitle can be inserted into your theme template files (or plugin) using the following API:

Display The Subtitle

All parameters are optional. If 'post_id' is omitted then the current post ID in the loop is used.

PHP Code:

do_action( 'plugins/wp_subtitle/the_subtitle', array( 'before' => '<p class="subtitle">', 'after' => '</p>', 'post_id' => get_the_ID(), 'default_value' => '' ) );

Output:

<p class="subtitle">My Post Subtitle</p>

Get The Subtitle

All parameters are optional. If 'post_id' is omitted then the current post ID in the loop is used.

A default value can be supplied as the second parameter for apply_filters. This will be used if the post does not have a subtitle. Leave as an empty string to return an empty string if the post does not have a subtitle.

PHP Code:

$subtitle = apply_filters( 'plugins/wp_subtitle/get_subtitle', '', array( 'before' => '<p class="subtitle">', 'after' => '</p>', 'post_id' => get_the_ID() ) );

Result:

$subtitle = '<p class="subtitle">My Post Subtitle</p>'

Parameters

The array of arguments accepted for the plugins/wp_subtitle/the_subtitle action and plugins/wp_subtitle/get_subtitle filter are:

before
(string) Text to place before the subtitle if one exists. Defaults to an empty string.

after
(string) Text to place after the subtitle if one exists. Defaults to to an empty string.

post_id
(integer) Post, page or custom post type ID.

default_value
(string) Only used by the plugins/wp_subtitle/the_subtitle action, allows you to specify a default subtitle to display if the post does not have one. For the plugins/wp_subtitle/get_subtitle filter the second parameter of apply_filters should be used instead. Defaults to to an empty string.

Post Type Support

By default, subtitle are supported by both posts and pages. To add support for custom post types add teh following to your theme functions file or plugin:

add_post_type_support( 'my_post_type', 'wps_subtitle' )

WooCommerce Plugin Support

Subtitles can automatically be added to your WooCommerce products without needing to make template changes. In the admin go to WooCommerce > Settings > Products where you can choose to:

  • Enable Product Subtitles
  • Display the subtitle on single product pages
  • Display the subtitle on product archives (category pages)

Yoast SEO and SEOPress Plugin Support

The plugin allows you to include the subtitle in your meta titles and descriptions via the Yoast SEO and SEOPress plugins.

Similar to the Yoast %%title%% placeholder which inserts the post title, you can use %%wps_subtitle%%.

There are also addition placeholders and filters to allow to to customize seperators for the subtitle.

For more information, view the SEO support documentation here.


Releases (25 )

Version Release Date Change Log
3.4.1 2022-04-22
  • Security: Resolve XSS issue by improving sanitization when saving subtitle custom field.
  • Pass the current post object to the wps_subtitle_field_placeholder filter. Props Dominik Schilling.
3.4 2020-02-08
  • Added support for the SEOPress plugin. Props @chriselkins.
  • You can now update the subtitle via the REST API. Props @chriselkins.
3.3.1 2020-01-29
  • Fixed broken closing H2 tag for WooCommerce subtitle. Props @faktorvier.
3.3 2019-09-04
  • New API for displaying the subtitle using do_action( 'plugins/wp_subtitle/the_subtitle' ).
  • New API for getting the subtitle using apply_filters( 'plugins/wp_subtitle/get_subtitle', '' ).
  • Admin column title now matches the meta box title if altered using the wps_meta_box_title filter.
3.2 2018-12-10
  • Fix WordPress 5.0 compatibility - check use_block_editor_for_post_type.
3.1 2018-09-06
  • Added %%wps_subtitle%% placeholders for Yoast SEO compatibility.
  • WooCommerce compatibility. Go to WooCommerce > Settings > Products > Display for settings.
  • Added wps_subtitle_field_position filter to show subtitle admin field before_title, after_title or in meta box.
  • Use metabox UI if editing in Gutenberg.
3.0 2017-09-06
  • Make wps_subtitle available via WordPress REST API.
2.9.1 2017-06-02
  • Fix preview not rendering correct template and other post meta.
2.9 2017-05-03
  • Add support for post revisions. Props Fabian Marz.
  • As of WordPress 4.3 no need to esc_attr() AND htmlentities() - can mess up special characters.
2.8.1 2016-09-14
  • Fix PHP warning - get_admin_subtitle_value() should be declared static.
2.8 2016-09-07
  • Allow subtitle to contain HTML (same as main post title ).
  • Add wps_default_subtitle filter.
  • Use WP_Subtitle class to validate saving of subtitle in the admin.
2.7.1 2016-09-07
  • Fix incorrect post ID reference preventing subtitle from saving.
2.7 2016-08-04
  • Trim subtitle by default.
  • Apply wptexturize() on subtitle.
  • Use WP_Subtitle class to manage post subtitle.
2.6 2015-12-08
  • Security Update: Sanitize $_REQUEST and $_GET when establishing post type in the admin.
  • Added quick edit support for subtitle. Props Fabian Marz and sun.
  • Allow subtitle post meta key to be filtered using wps_subtitle_key.
  • Add German translation. Props hatsumatsu.
2.5 2015-08-19
  • Add [wp_subtitle] shortcode.
  • Declare methods as public or private.
  • Do not use variable for textdomain - causes issues for parsers.
2.4.1 2015-06-09
  • Fix PHP notice warning on 404 error page. Props Jay Williams.
  • Add a little space above subtitle field when below title field in admin.
2.4 2015-04-28
  • Add subtitle admin column.
2.3.2 2015-02-10
  • Show subtitle admin field when adding new post. Props Gabriel Doty.
2.3.1 2014-10-03
  • Security Update: Ensure subtitles are sanitized when saving.
2.3 2014-09-05
  • Prevent subtitle fields from displaying on post types for which support has not been added using add_post_type_support(). Previously the fields were displayed but the subtitle would not be saved.
  • Escape subtitle admin field value - fixes issues with subtitles with quotes.
2.2 2014-07-02
  • Moved subtitle field from meta box to below title field in WordPress 3.5+ (props Tor Morten)
  • Added 'wps_subtitle_use_meta_box' filter to allow the edit field to be displayed in a meta box (the old way).
2.1 2014-03-12
  • Ready for translation - .pot file added.
  • Only include admin functionality when needed.
  • Added deprecated function warnings if WP_DEBUG enabled.
  • Fix static method warnings.
2.0.1 2013-09-18
  • Use <?php instead of just <?.
  • Break out some of the code into separate functions.
2.0 2013-07-29
  • Added custom post type support - use add_post_type_support( '{post_type}', 'wps_subtitle' ).
  • Fixed bug in more recent versions of WordPress.
  • Added 'wps_meta_box_title' filter.
  • Added 'wps_subtitle' filter.
  • Added 'wps_subtitle_field_description' filter.
1.0 2009-07-10