WP Subtitle

Beschreibung

Mit dem Plugin WP Subtitle kannst du Untertitel (Sub-Headlines, Dachzeilen) in deine Seiten und Beiträge einfügen. Dieser Zusatz zur Überschrift steht üblicherweise vor oder nach der Haupt-Überschrift, du kannst ihn jedoch in deine Templates einbauen, wo du möchtest.

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

Subheadline anzeigen

Alle Parameter sind optional. Wenn „post_id“ nicht übergeben wird, dann wird die aktuelle Beitrags-ID aus dem Loop benutzt.

PHP-Code:

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

Ausgabe:

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

Die Subheadline abrufen

Alle Parameter sind optional. Wenn „post_id“ nicht übergeben wird, dann wird die aktuelle Beitrags-ID aus dem Loop benutzt.

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()
) );

Ergebnis:

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

Einstellungen

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.

Unterstützte Inhaltstypen

Standardmäßig unterstützen sowohl Seiten als auch Beiträge das Einfügen von Subheadlines. Um eigene Inhaltstypen zu unterstützen, füge den folgenden Code in die Datei „functions.php“ deines Themes oder Plugins ein:

add_post_type_support( 'my_post_type', 'wps_subtitle' )

Unterstützung für das Plugin „WooCommerce“

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:

  • Produkt-Untertitel aktivieren
  • Display the subtitle on single product pages
  • Display the subtitle on product archives (category pages)

Unterstützung für das Plugin „Yoast SEO“

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

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 Yoast SEO documentation here.

Screenshots

  • Edit post screen (WordPress 5.0+ and WP Title 3.1+)
  • Edit post screen (WordPress 3.5+ and WP Title 2.2+)
  • Edit post screen (for earlier versions of WordPress or using the 'wps_subtitle_use_meta_box' filter)
  • Eine einzelne Seite mit Untertitel

Installation

  1. Upload the WP Subtitle plugin to your WordPress site in the /wp-content/plugins folder or install via the WordPress admin.
  2. Activate it from the WordPress plugin admin screen.
  3. Use the API to display the subtitle in your theme.

For full details on the API and how to display the subtitle, view the documentation here.

FAQ

Was macht WP Subtitle?

The plugin adds a Subtitle field when editing posts, pages or custom post types. The subtitle is stored as a custom field (post meta data) and can be output using API actions and filters.

Wo speichert WP Subtitle die Untertitel?

All subtitles are stored as post meta data. Deactivating this plugin will not remove those fields.

Kompatibilität mit WordPress 5.0 und höher

In the new editor in WordPress 5.0 the subtitle is editable via ap panel in the sidebar (like excerpts).

Wie baue ich die Untertitel (Subheadlines) in meine Seiten ein?

Schau dir die Dokumentation (englisch) an.

Wie ergänze ich die Unterstützung eigener Inhaltstypen?

Um eigene Inhaltstypen zu unterstützen, füge den folgenden Code in die Datei „functions.php“ deines Themes oder Plugins ein:

function my_wp_subtitle_page_part_support() {
    add_post_type_support( 'my_post_type', 'wps_subtitle' );
}
add_action( 'init', 'my_wp_subtitle_page_part_support' );
Wo kann ich Hilfe bekommen?

Bitte stelle deine Fragen und Supportanfragen im Support-Forum unter WordPress.org.

Wie sollte ich einen Fehler melden?

Bitte melde Fehler direkt bei GitHub Issues.

Wie kann ich zum Code beitragen?

Das Plugin liegt auf GitHub und Pull-Requests sind willkommen.

Rezensionen

14. Juni 2019
Does what it advertises efficiently. I give it 4-stars as it needs a bit of development support on the theme templates to display the subtitles --- not quite plug-and-play
27. März 2018
Thank you very much for that plugin. It works perfectly in multiple of my clients installations. For the fifth star: It would be very convenient (for me) to have the default behaviour of get_the_subtitle() changed to return the content rather than echo it. 1. It would go along with the behaviour of WordPress built-in functions ( get_the_title(), get_the_content() etc.) 2. I have to provide 3 extra paramters ( $before, $after and $echo ) everytime I want to do this simple switch. Another suggestion would be to check if $post is already set and use it automatically if so. (That way i wouldnt have to use any params at all in most of my use-cases. ...and YES, I am lazy 😉 )
Lies alle 19 Rezensionen

Mitwirkende & Entwickler

„WP Subtitle“ ist Open-Source-Software. Folgende Menschen haben an diesem Plugin mitgewirkt:

Mitwirkende

„WP Subtitle“ wurde in 4 Sprachen übersetzt. Danke an die Übersetzerinnen und Übersetzer für ihre Mitwirkung.

Übersetze „WP Subtitle“ in deine Sprache.

Interessiert an der Entwicklung?

Durchstöbere den Code, sieh dir das SVN Repository an oder abonniere das Entwicklungsprotokoll per RSS.

Änderungsprotokoll

3.3

  • 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

  • Fix WordPress 5.0 compatibility – check use_block_editor_for_post_type.

3.1

  • 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

  • Make wps_subtitle available via WordPress REST API.

2.9.1

  • Fix preview not rendering correct template and other post meta.

2.9

  • 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

  • Fix PHP warning – get_admin_subtitle_value() should be declared static.

2.8

  • 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

  • Fix incorrect post ID reference preventing subtitle from saving.

2.7

  • Trim subtitle by default.
  • Apply wptexturize() on subtitle.
  • Use WP_Subtitle class to manage post subtitle.

2.6

  • 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

  • Add [wp_subtitle] shortcode.
  • Do not use variable for textdomain – causes issues for parsers.
  • Declare methods as public or private.

2.4.1

  • 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

  • Add subtitle admin column.

2.3.2

  • Show subtitle admin field when adding new post. Props Gabriel Doty.

2.3.1

  • Security Update: Ensure subtitles are sanitized when saving.

2.3

  • 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

  • Added ‚wps_subtitle_use_meta_box‘ filter to allow the edit field to be displayed in a meta box (the old way).
  • Moved subtitle field from meta box to below title field in WordPress 3.5+ (props Tor Morten)

2.1

  • Ready for translation – .pot file added.
  • Added deprecated function warnings if WP_DEBUG enabled.
  • Fix static method warnings.
  • Only include admin functionality when needed.

2.0.1

  • Use <?php instead of just <?.
  • Break out some of the code into separate functions.

2.0

  • Added custom post type support – use add_post_type_support( ‚{post_type}‘, ‚wps_subtitle‘ ).
  • Added ‚wps_meta_box_title‘ filter.
  • Added ‚wps_subtitle‘ filter.
  • Added ‚wps_subtitle_field_description‘ filter.
  • Fixed bug in more recent versions of WordPress.

1.0

  • First version.