Last active
January 23, 2019 19:00
-
-
Save lithiumlab/110b5d46aa2bf8f280e2154dd0ffb4d6 to your computer and use it in GitHub Desktop.
WP Conditional page Title Update
This file contains hidden or 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 | |
// probably in functions.php .... | |
add_filter('wp_title', 'thisdomain_news_archive_title'); | |
function thisdomain_news_archive_title($title) { | |
//check if its a blog post | |
if (!is_single()) | |
return $title; | |
//if you get here then its a blog post so change the title | |
global $wp_query; | |
if (isset($wp_query->post->post_title)){ | |
// update here to what you need | |
return $wp_query->post->post_title; | |
} | |
//if wordpress can't find the title return the default | |
return $title; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment