Last active
September 5, 2018 01:57
-
-
Save tomaskavalek/f2970de5df3c0a43b3fa7c74dbf6e9fb to your computer and use it in GitHub Desktop.
Wordpress – Customize archive page title for selected post type
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 | |
/** | |
* @param $title | |
* @return array | |
*/ | |
function archive_titles($title): array | |
{ | |
global $post; | |
if ( ! isset($post->post_type)) { | |
return $title; | |
} | |
$type = $post->post_type; | |
$types = [ | |
'custom_post_type' => 'Custom title', | |
]; | |
if (is_archive() && isset($types[$type])) { | |
$title['title'] = $types[$type]; | |
} | |
return $title; | |
} | |
add_filter('document_title_parts', 'archive_titles'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment