Linux 软件免费装
Banner图

KIA Subtitle

开发者 helgatheviking
更新时间 2024年4月25日 02:57
捐献地址: 去捐款
PHP版本: 6.1 及以上
WordPress版本: 6.5.0
版权: GPLv3 or later
版权网址: 版权信息

标签

simple subtitle

下载

1.6.2 3.0.3 1.1 1.1.2 1.2 1.3.1 1.3.3 1.3.4 1.4.1 1.4.2 1.5 1.5.1 1.5.3 1.5.4 1.6 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 2.0.0 3.0.2 1.0.1 1.0.2 1.0.3 1.3 4.0.0 4.0.1

详情介绍:

KIA subtitle allows you to add a subtitle to your posts and retrieve it in the loop in the same manner as the post title. By using the Subtitle block or the the_subtitle() or get_the_subtitle() template tags. It adds an input field right under the title field of posts, pages and any custom post type. It also add a subtitle column to the edit screen as well as to the quick edit. You can also use the Subtitle block or the shortcode [the-subtitle] to display it within the post content.

安装:

  1. Upload the plugin folder to the /wp-content/plugins/ directory
  2. 通过 WordPress 的“插件”菜单激活插件
  3. For Block Themes: Add the subtitle block to your template in the Site Editor
  4. For Classic Themes: Add the 'the_subtitle()' tag to your theme

屏幕截图:

  • Insert a subtitle block into your block theme's template, such as the Singular template for displaying Posts.
  • This is what the input will look like in the Classic Editor.

常见问题:

How do I display the subtitle in my theme?

The intended way is with the the_subtitle() template tag as follows: if ( function_exists( 'the_subtitle' ) ) the_subtitle(); You can wrap the string in some markup using the $before and $after parameters. if ( function_exists( 'the_subtitle' ) ) the_subtitle( '<h2 class="subtitle">', '</h2>' ); As an absolute worst case fallback you could also add the following snippet to your functions.php in order to prepend the subtitle to the content. ` /**

  • Prepend the subtitle to the post content.
  • @param string $content The post content
  • @return string */ function kia_prepend_subtitle_to_content( $content ) { if ( ! is_admin() ) {
$subtitle = function_exists( 'get_the_subtitle' ) ? get_the_subtitle() : ''; if ( ! empty( $subtitle ) ) { $content = ' ' . wp_kses_post( $subtitle ) . '' . $content; } } return $content; } add_filter( 'the_content', 'kia_prepend_subtitle_to_content' ); You could also filterthe_titleand but it would have to be part of the post title's markup and could not have it's own markup as nesting header elements is invalid HTML markup. /**
  • Append the subtitle to the title.
  • @param string $title The post title
  • @return string */ function kia_append_subtitle_to_title( $title ) { if ( ! is_admin() ) { $subtitle = function_exists( 'get_the_subtitle' ) ? get_the_subtitle() : '';
if ( ! empty( $subtitle ) ) { $title .= ' — ' . wp_kses_post( $subtitle ); } } return $title; } add_filter( 'the_title', 'kia_append_subtitle_to_title' ); `

Where do I add this code?

Unfortunately, I cannot tell you exactly what file to place the above code in because 1. I don't know where you want to display the subtitle and 2. every theme's structure is different. However, in general, the_subtitle() is a template tag so you will want to put it in a template file. Probably, you are looking for the file that contains your post loop. For most themes it's single.php ( or page.php for pages ), but for many it could also be content.php. Assuming you want the subtitle to display directly after your main title, you'd place the above code after: ` ` As an example if you wanted to display the subtitle on standard single posts, in the Twenty Twenty theme you'd create a copy of the entry-header.php template in your child theme and modify it as shown in this gist

How do I style the subtitle?

If you have wrapped the subtitle in an H2 tag with the class of subtitle like in the gist above, you can then style it any way you'd like. .subtitle { color: pink; }

Can I display the subtitle for my WooCommmerce products

Yes! You can use this bridge plugin to automatically display the subtitle in most WooCommerce locations.

Can I add the subtitle to the Page Title Meta tag

function kia_add_subtitle_to_wp_title( $title ) { if ( is_single() && function_exists( 'get_the_subtitle' ) ) && $subtitle == get_the_subtitle( get_the_ID() ) ) { $title .= $subtitle; } } add_filter( 'wp_title', 'kia_add_subtitle_to_wp_title' );

Is this translation ready?

WPML now supports KIA Subtitle!

更新日志:

4.0.1 4.0.0 3.0.3 3.0.2 3.0.1 3.0.0 2.0.0 1.6.8 1.6.7 1.6.6 1.6.5 1.6.4 1.6.3 1.6.2 1.6.1 1.6 1.5.4 1.5.4 1.5.3 1.5.2 1.5.1 1.5 1.4.3 1.4.2 1.4.1 1.4 1.3.4 1.3.3 1.3.2 1.3.1 1.3 1.2 1.1.2 1.1.1 1.1 1.0.2 1.0.1 1.0