Is there anything that will allow me to set the title of a custom post type archive page similar to the filter descriptions given in #26 - Meta Description for Custom Post Type Archive pages
It still requires development.
In the meantime, you can use the exact same filter as you've found here:
https://github.com/sybrew/the-seo-framework/issues/26#issuecomment-248559457
But, because WordPress also handles the title, it will be slightly different.
add_filter( 'the_seo_framework_ogtitle_output', 'my_special_title', 10, 2 );
add_filter( 'the_seo_framework_twittertitle_output', 'my_special_title', 10, 2 );
/**
* Alters the title on special conditions.
*
* @param string $title The current title.
* @param int $id The Post, Page or Term ID.
* @return string Title. Does not need to be escaped.
*/
function my_special_title( $title= '', $id = 0 ) {
/**
* @link https://developer.wordpress.org/reference/functions/is_post_type_archive/
*/
if ( is_post_type_archive( 'my_post_type_name' ) ) {
$title = 'My super title';
}
return $title;
}
add_filter( 'the_seo_framework_pro_add_title', 'my_special_page_title', 10, 3 );
/**
* Alters the title on special conditions.
*
* @param string $title The current title.
* @param array $args The title generation arguments.
* @param bool $escape Whether the title is being escaped.
* @return string Title. Does not need to be escaped.
*/
function my_special_page_title( $title= '', $args = array(), $escape = true ) {
/**
* @link https://developer.wordpress.org/reference/functions/is_post_type_archive/
*/
if ( is_post_type_archive( 'my_post_type_name' ) ) {
$title = 'My super title';
}
return $title;
}
For feature references, since the code above didn't work for me.
Set custom post type archive titles – https://theseoframework.com/docs/api/filters/
add_filter( 'the_seo_framework_title_from_generation', function( $title= '', $args = [] ) {
/**
* @link https://developer.wordpress.org/reference/functions/is_post_type_archive/
*/
if ( is_post_type_archive( 'my_post_type_name' ) ) {
$title = 'My custom title';
}
return $title;
}, 10, 2);
Most helpful comment
For feature references, since the code above didn't work for me.
Set custom post type archive titles – https://theseoframework.com/docs/api/filters/