Secondary Title

Secondary Title is a simple, lightweight WordPress plugin that adds an alternative title input field to posts, pages and custom post types. It comes with a settings page that lets you customize the plugin and set for which post/page IDs, categories or post types should be activated. Secondary Title can either be used automatically or manually inserted into the theme file.

Installation

  • Install Secondary Title either through WordPress´ native plugin installer (Plugins > Install) or copy the secondary-title folder into your /wp-content/plugins/ directory.
  • Activate the plugin in the plugin section of your admin interface.
  • Go to Settings > Secondary Title to customize the plugin as desired.

Usage

To automatically add the secondary title to the standard title, go to Settings > Secondary Title and select “Insert automatically”. The “Title format” below lets you customize the way the titles are being shown. If “Insert automatically” is set to “No”, you have to use either <?php echo get_secondary_title($post_id, $prefix, $suffix); ?> or <?php the_secondary_title($post_id, $prefix, $suffix); ?> in your theme file(s) wherever you want to display the secondary title.

Note: If you want to display the secondary title within a loop, you can set $post_id to 0 to automatically get the current post ID, otherwise you have to specify the ID of the post.

Parameters

Returns the secondary title for the current post.

$post_id (integer) (optional) The ID of the post whose secondary title should be displayed. If within a loop, leave empty or use 0 to get the current post ID. Default: get_the_ID()

$prefix (string(optional) A prefix that will be displayed in front of the secondary title. Default: None

$suffix (string) (optional) A suffix that will be displayed at the end of the secondary title. Default: None

Displays the secondary title for the current post. Parameters are the same as <?php get_secondary_title(); ?> .

Displays the secondary title as a formatted HTML link to the post.

$post_id (integer) (optional): The ID of the post whose secondary title should be displayed. If within a loop, leave empty or use 0 to get the current post ID. Default: get_the_ID()

$wrapper (string) (optional): A HTML element (e.g. h4, p, …) wrapped around the displayed link. Default: Empty

$options (array) (optional): An array containing additional options:

  • before_link: String displayed before the link elements. Default: Empty
  • after_link: String displayed after the link elements. Default: Empty
  • before_text: String disSeitenplayed before the link text. Default: Empty
  • before_text: String displayed after the link text. Default: Empty
  • link_text: Link text that will be displayed. Default: The secondary title.
  • link_target: target=”” attribute for the “a href” element. Default_self
  • link_title: title=”” attribute for the “a href” element (displayed on mouseover). Default: Empty
  • link_id: id=”” attribute for the “a href” element. Defaultsecondary-title-link-$post_id
  • link_class: class=”” attribute for the “a href” element. Defaultsecondary-title-link

Checks whether the current post has a secondary title or not. Returns true or false.

$post_id (integer) (optional): See above.

Examples

1. Only display the secondary title:

2. Using the standard and secondary title in the post´s head:

Displays:  +++ Plane missing +++ Malaysian Airlines flight MH370 lost over Gulf of Thailand

3. Display the secondary title of the last 5 posts:

4. Display the secondary title of a specific post:

This will display the post with the post ID 28.

5. Display the secondary title in red and the standard title in the default color:

FAQ

How do I use this plugin?

For installation and usage instructions, please see the installation section. There, you will also find several examples.

The secondary title is not being added to the standard title.

Please verify whether the option “Insert automatically” is set to “Yes”. Don´t forget to enter a valid title format that uses both the standard and the secondary title. Leaving the title format blank will not show anything at all.

The secondary title is still not shown.

Make sure the post is in the allowed post types and/or categories set on the settings page. Also, if you have specified any post IDs, the secondary title will only be shown on these posts. Leave post types, categories and post IDs blank to deactivate this function.

How can I add styles (colors, fonts etc.) to the auto title?

You can add any HTML element you want in the title format found in Settings > Secondary Title, e.g.:

This will display the secondary title in red with a font size of 12px, the standard post title won`t be changed. If you want the styled secondary title only to be displayed in a certain place (e.g. inside of the home posts), you will have to define a class and define it in the style.css stylesheet file of your active theme.

How can I add styles with the manual secondary title?

To style the output of <?php the_secondary_title(); ?> or <?php get_secondary_title(); ?> , you can use HTML in PHP:

Same as above, this will display the secondary title in red and with a font size of 12px.

Since version 0.6 you can set whether the the secondary title should be should be shown everywhere or exclusively on the main post. If activated, it won´t be shown in sidebars, menu items etc.

How to display the secondary title above/below the main title with turned on auto show?

You can insert line breaks with the <br /> HTML tag. Example:

Changelog

0.8

  • Some new minor functions and changes on the settings page.
  • Allowed to use %title% and %secondary_title% variable on settings page > title format more than once.
  • Added option to use secondary title in permalinks.
  • Added filter hooks to get_secondary_title(), the_secondary_title() and get_secondary_title_link() PHP functions.
  • Added French translation (thanks to fxbenard).
  • Updated existing translations.
  • Fixed bug that prevented the secondary title to be updated when empty.
  • Renamed get_filtered_post_types() to get_secondary_title_filtered_post_types() to avoid possible conflicts.

0.7

  • Restructured and split up plugin code into different files for better handling.
  • Added “Secondary title” column to posts/pages overview.
  • Added secondary title input field to quick edit box on posts/pages overview.
  • Removed secondary title from above/below the standard title on posts/page overview.
  • Renamed functions to minimize conflicts with other plugins.
  • Updated screenshot.
  • Bug fixes.

0.6

  • Added compatibility with Word Filter Plus plugin.
  • Added “Only show in main post” setting.
  • Fixed minor jQuery bug on admin interface.
  • Updated FAQ.

0.5.1

  • Fixed bug that falsely added slashes to HTML attributes in title format.
  • Fixed jQuery bug in the admin posts/pages.
  • Added <?php has_secondary_title(); ?>  function. See Parameters section for more information.

0.5

  • Fixed bug where the secondary title was not shown if the standard title contains “…” (thanks to Vangelis).
  • Added “select/unselect all” function for checkbox lists on settings page.
  • Added secondary title display in admin posts/pages list.
  • Added <?php get_secondary_title_link($post_id, $options); ?>  and <?php the_secondary_title_link($post_id, $options); ?>  functions to quickly create the secondary title as a link to its post. See the official documentary for more information.
  • Updated documentary/readme.txt.

0.4

  • Fixed bug that showed secondary title input within the post/page overview.
  • Added Italian translation (thanks to giuseppep).
  • Added Polish transation (thanks to pawel10).
  • Updated existing translations.

0.3

  • Added HTML support in title format (thanks to C0BALT).
  • Added option to set the position of the secondary title input field within the admin interface (thanks to Vangelis).
  • Added translation to Thai.
  • Updated translation files.

0.2

  • Installs default values on first plugin activation.
  • Added screenshots.
  • Added $suffix and $prefix parameter for  <?php get_secondary_title(); ?>
  • Updated plugin documentation and information at WordPress.org

0.1

  • Initial release.

Upgrade Notice

0.8

Permalinks support, bug fixes, translation updates.

0.7

Major changes; restructured plugin files, added “Secondary title” column to posts/page overview and more.

0.6

Bug fixes, setting added, compatibility with Word Filter Plus plugin.

0.5.1

Hotfix for 0.5.

0.5

Bug fixes and some more features.

0.4

Bug fix and translation update.

0.3

HTML support and new features.

0.2

Major changes, screenshots, FAQ, parameters.

0.1

This is the first release of Secondary Title.