Created
November 9, 2017 15:36
-
-
Save asharirfan/cb941719554fb93341f3566fd66636c4 to your computer and use it in GitHub Desktop.
WPC — Add site title to every post title.
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 | |
/** | |
* Add Site Title. | |
* | |
* Add site title to every post title. | |
* | |
* @param string $title - Title of the post. | |
*/ | |
function wpc_add_sitename_to_title( $title ) { | |
// Get the site title. | |
$site_name = get_bloginfo( 'name' ); | |
// Concatenate the site name to the post title. | |
$title = $site_name . ' — ' . $title; | |
// Return the modified title. | |
return $title; | |
} | |
// Hook it! | |
add_filter( 'the_title', 'wpc_add_sitename_to_title', 10, 1 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment