Skip to content

Quick Start

Start using Secondary Title on your WordPress site to add an extra title field to your posts, pages, and custom post types. The secondary title can be displayed in three different ways:

  1. Automatically
  2. Manually
  3. Using a shortcode

1. Automatic Display

After installing and activating the plugin, Secondary Title works out-of-the-box with minimal default settings. Your post editor will now have an additional input field on the right hand side of your screen where you can enter the secondary title.

DEFAULT TITLE FORMAT

It is essential to note that the Title Format determines how the secondary title is displayed. The default title format is simple: secondary title, then primary title, separated by a colon (:).

A post with the primary title Hello World! and the secondary title Welcome will therefore change from

text
Hello World!

to

text
Hello World!: Welcome

To change the title format, edit the Title Format setting on the plugin's settings page (Settings -> Secondary Title). You can use the following placeholders:

Placeholders

  • %title%: The primary title of the post
  • %secondary_title%: The secondary title of the post

MORE INFORMATION

Learn more about this and every other setting in the Settings section.

2. Manual Display

If you like to display the secondary title in a specific location or when the setting "Auto Show" is set to "Off", you can do so by adding the following code to your theme file(s) (e.g., single.php, typically found in the /wp-content/themes/YOUR-THEME directory):

php
<?php echo get_secondary_title($post_id, $prefix, $suffix); ?>

For additional customization:

php
<?php the_secondary_title($post_id, $prefix, $suffix); ?>

All parameters are optional. For a full list of available parameters, see the section about this function on the functions reference page.

CAUTION

To avoid the PHP fatal error Call to undefined function the_secondary_title() which breaks your site if the plugin is not installed or activated, it's highly recommended to wrap the function in a conditional statement. Here's an example:

php
if (function_exists('the_secondary_title')) {
    the_secondary_title();
}

3. Using a Shortcode

The secondary title can be displayed anywhere in your post content by using this simple shortcode:

text
[secondary_title]

This will display the secondary title of the current post. Additional parameters can be added to the shortcode as seen in this example:

text
[secondary_title post_id="123" allow_html="true"]

Parameters

  • post_id: (int) The ID of the post to display the secondary title from
  • allow_html: (bool) Whether to allow HTML in the secondary title

For a full list of available parameters, see the Shortcodes reference page.