Created
April 16, 2024 23:21
-
-
Save sybrew/971e49138e0841fa18a413a6bd24e561 to your computer and use it in GitHub Desktop.
Sets TSF taxonomy title parts for taxonomy 'module'.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Do not include the PHP opening tag if PHP is already open. | |
// For request: https://wordpress.org/support/topic/way-to-automatically-create-custom-meta-titles/ | |
add_filter( | |
'the_seo_framework_generated_archive_title_items', | |
/** | |
* @param String[title,prefix,title_without_prefix] $items The generated archive title items. | |
* @param \WP_Term|\WP_User|\WP_Post_Type|null $object The archive object. | |
* Is null when query is autodetermined. | |
* @param string $title_without_prefix Archive title without prefix. | |
* @param string $prefix Archive title prefix. | |
* @return String[title,prefix,title_without_prefix] Modified $items with " article" appended for taxonomy 'module'. | |
*/ | |
function ( $items, $object, $title, $title_without_prefix, $prefix ) { | |
if ( isset( $object ) ) { | |
// Admin area | |
$is_module = 'module' === ( $object->taxonomy ?? '' ); | |
} else { | |
// Front-end | |
$is_module = is_tax( 'module' ); | |
} | |
if ( $is_module ) { | |
// $items[0] = $title. | |
$items[0] = "$title article"; | |
// $items[2] = $title_without_prefix. | |
$items[2] = "$title_without_prefix article"; | |
} | |
return $items; | |
}, | |
10, | |
5, | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment