{"id":20686248,"url":"https://github.com/helgatheviking/kia-subtitle","last_synced_at":"2025-07-02T14:36:39.174Z","repository":{"id":3786871,"uuid":"4864822","full_name":"helgatheviking/KIA-Subtitle","owner":"helgatheviking","description":"Add a subtitle meta field","archived":false,"fork":false,"pushed_at":"2024-05-28T15:13:10.000Z","size":1239,"stargazers_count":7,"open_issues_count":2,"forks_count":5,"subscribers_count":4,"default_branch":"trunk","last_synced_at":"2025-04-22T13:55:00.140Z","etag":null,"topics":["hacktoberfest","meta","subtitle","wordpress"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/helgatheviking.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2012-07-02T20:59:15.000Z","updated_at":"2024-08-30T01:15:14.000Z","dependencies_parsed_at":"2024-11-16T22:32:04.033Z","dependency_job_id":"6de59eab-c337-4d50-bd30-7e10d27ee96c","html_url":"https://github.com/helgatheviking/KIA-Subtitle","commit_stats":null,"previous_names":[],"tags_count":35,"template":false,"template_full_name":null,"purl":"pkg:github/helgatheviking/KIA-Subtitle","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helgatheviking%2FKIA-Subtitle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helgatheviking%2FKIA-Subtitle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helgatheviking%2FKIA-Subtitle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helgatheviking%2FKIA-Subtitle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/helgatheviking","download_url":"https://codeload.github.com/helgatheviking/KIA-Subtitle/tar.gz/refs/heads/trunk","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/helgatheviking%2FKIA-Subtitle/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263157470,"owners_count":23422632,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest","meta","subtitle","wordpress"],"created_at":"2024-11-16T22:31:38.819Z","updated_at":"2025-07-02T14:36:39.144Z","avatar_url":"https://github.com/helgatheviking.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# KIA Subtitle #\n\nThe KIA Subtitle plugin allows you to add a subtitle to your posts.\n\nThis is a developmental repo. Clone this repo and run `npm install \u0026\u0026 npm run release`   \nOR    \n|[Download latest release](https://github.com/helgatheviking/KIA-Subtitle/releases/latest)|\n\n\n## Description ##\n\nKIA 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`.\n\nIt 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.\n\nYou can also use the Subtitle block or the shortcode `[the-subtitle]` to display it within the post content.\n\n## Installation ##\n\n1. Upload the `plugin` folder to the `/wp-content/plugins/` directory\n1. Activate the plugin through the 'Plugins' menu in WordPress\n1. *For Block Themes:* Add the subtitle block to your template in the Site Editor\n1. *For Classic Themes:* Add the 'the_subtitle()' tag to your theme\n\n## Site Editor ##\n\nThe plugin provides a Subtitle block in the editor. In the post editor, this doesn't make a lot of sense, but mimics the core Title block. The ideal use case for the Subtitle block is when editing your theme\n\n1. Click Edit Site in the WordPress toolbar\n1. Select the template you wish to edit, commonly this might be called Single Post, or Singular.\n1. Insert the Subtitle block where needed, commonly right after the Title block.\n\n## Template Tags ##\n\nThis plugin does _not_ attempt to output the subtitle. With an infinite number of themes, it is not possible for us to support that. The onus is on the user to customize their theme accordingly. The plugin provides two template tags that can be used to customize your theme as desired.\n\n= `the_subtitle( string $before = ”, string $after = ”, bool $display = true ): void|string` =\n\nDisplays or retrieves the current post subtitle with optional markup.\n\n*Parameters*\n\n`$before` `string` `optional`\n    Markup to prepend to the title.\n    Default: `''`\n\n`$after` `string` `optional`\n    Markup to append to the title.\n    Default: `''`\n\n`$display` `bool` `optional`\n    Whether to echo or return the title. Default true for echo.\n    Default: `true`\n\n\nExample usage:\n\n`if ( function_exists( 'the_subtitle' ) ) the_subtitle( '\u003ch2 class=\"subtitle\"\u003e', '\u003c/h2\u003e' );`\n\n### `get_the_subtitle( int|WP_Post $post ): string` ###\n\nRetrieves the post subtitle.\n\n*Parameters*\n\n`$post` `int|WP_Post` `optional`\n    Post ID or WP_Post object.\n    Default: global `$post` object.\n\n\n`\n\n### WooCommerce support ###\n\nThere is a small [bridge plugin](https://github.com/helgatheviking/kia-subtitle-woocommerce-bridge) you can install and activate to automatically display the subtitle in most WooCommerce locations. This will work for all themes that are using WooCommerce's default hooks.\n\n*NB:* It's known that the Ocean WP theme has it's own hooks in the WooCommerce templates. You will need to alter the bridge plugin... please take a look at this [support thread](https://wordpress.org/support/topic/compatibility-with-latest-wp-and-wc/#post-15456180).\n\n\n### WPML Ready ###\n\nKIA Subtitle has been tested by WPML and will allow you to translate the subtitle on multilingual sites.\n\n### Support ###\n\nSupport is handled in the [WordPress forums](http://wordpress.org/support/plugin/kia-subtitle). Please note that support is limited and does not cover any custom implementation of the plugin.\n\nPlease report any bugs, errors, warnings, code problems to [Github](https://github.com/helgatheviking/KIA-Subtitle/issues)\n\n## Screenshots ##\n\n1. This is what the input will look like in the Block Editor.\n1. Insert a subtitle block into your block theme's template, such as the Singular template for displaying Posts.\n1. This is what the input will look like in the Classic Editor.\n\n## Frequently Asked Questions ##\n\n### How do I display the subtitle in my theme? ###\n\nThe intended way is with the `the_subtitle()` template tag as follows:\n\n\tif ( function_exists( 'the_subtitle' ) ) the_subtitle();\n\n\nYou can wrap the string in some markup using the *$before* and *$after* parameters.\n\n\tif ( function_exists( 'the_subtitle' ) ) the_subtitle( '\u003ch2 class=\"subtitle\"\u003e', '\u003c/h2\u003e' );\n\n\nAs 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. \n\n\t/**\n\t * Prepend the subtitle to the post content. \n\t *\n\t * @param string $content The post content\n\t * @return string\n\t */\n\tfunction kia_prepend_subtitle_to_content( $content ) {\n\t\tif ( ! is_admin() ) {\n\t\n\t\t\t$subtitle = function_exists( 'get_the_subtitle' ) ? get_the_subtitle() : '';\n\t\n\t\t\tif ( ! empty( $subtitle ) ) {\n\t\t\t\t$content = '\u003ch2 class=\"subtitle\"\u003e' . wp_kses_post( $subtitle ) . '\u003c/h2\u003e' . $content;\n\t\t\t}\n\t\t}\n\t\treturn $content;\n\t}\n\tadd_filter( 'the_content', 'kia_prepend_subtitle_to_content' );\n\n\nYou could also filter `the_title` and 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.\n\n\t/**\n\t * Append the subtitle to the title. \n\t *\n\t * @param string $title The post title\n\t * @return string\n\t */\n\tfunction kia_append_subtitle_to_title( $title ) {\n\t\tif ( ! is_admin() ) {\n\t\t\t$subtitle = function_exists( 'get_the_subtitle' ) ? get_the_subtitle() : '';\n\t\n\t\t\tif ( ! empty( $subtitle ) ) {\n\t\t\t\t$title .= ' \u0026mdash; ' . wp_kses_post( $subtitle );\n\t\t\t}\n\t\t}\n\t\treturn $title;\n\t}\n\tadd_filter( 'the_title', 'kia_append_subtitle_to_title' );\n\n\n### Where do I add this code? ###\n\nUnfortunately, 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.\n\nHowever, 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:\n\n\n\t\u003ch1 class=\"entry-title\"\u003e\u003c?php the_title(); ?\u003e\u003c/h1\u003e\n\n\nAs 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](https://gist.github.com/helgatheviking/6754a8a381ace9aef325ca3f7b4128c1)\n\n### How do I style the subtitle? ###\n\nIf 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.\n\n\t.subtitle { color: pink; }\n\n\n### Can I display the subtitle for my WooCommmerce products ###\n\nYes! You can use this [bridge plugin](https://github.com/helgatheviking/kia-subtitle-woocommerce-bridge) to automatically display the subtitle in most WooCommerce locations.\n\n### Can I add the subtitle to the Page Title Meta tag ###\n\n\tfunction kia_add_subtitle_to_wp_title( $title ) {\n\t\tif ( is_single() \u0026\u0026 function_exists( 'get_the_subtitle' ) ) \u0026\u0026 $subtitle == get_the_subtitle( get_the_ID() ) ) {\n\t\t$title .= $subtitle;\n\t\t}\n\t}\n\tadd_filter( 'wp_title', 'kia_add_subtitle_to_wp_title' );\n\n\n### Is this translation ready? ###\nWPML now supports KIA Subtitle!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhelgatheviking%2Fkia-subtitle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhelgatheviking%2Fkia-subtitle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhelgatheviking%2Fkia-subtitle/lists"}