Skip to content

Instantly share code, notes, and snippets.

@asharirfan
Created November 9, 2017 15:36
Show Gist options
  • Save asharirfan/cb941719554fb93341f3566fd66636c4 to your computer and use it in GitHub Desktop.
Save asharirfan/cb941719554fb93341f3566fd66636c4 to your computer and use it in GitHub Desktop.
WPC — Add site title to every post title.
<?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