Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Is it possible to have the site title prepended before each post title, separated by a hyphen? For example:

[my site title] - [my post title]
share|improve this question
add comment

1 Answer

up vote 4 down vote accepted
function prepend_site_name($title) {
  return get_bloginfo('name').' - '.$title;
}
add_filter('the_title','prepend_site_name');

Like that?

share|improve this answer
    
Ok, thanks. If it can't be done in the WP admin, I'll need to see how this translates into Thesis 2's non PHP platform. –  4thSpace Dec 1 '12 at 17:45
    
If you don't mind using a plugin, you could install Yoast SEO plugin. This will also add a ton of other SEO features you might not want, so before you install please inform yourself on this plugin. If you do decide to use this plugin anyway: Just enter your desired settings under "SEO >> titels & meta's" In your case: > %%sitename%% - %%title%% –  bertkat Dec 11 '12 at 13:11
    
Given that Yoast SEO simply filters the_title, using the method described in the accepted answer, this really doesn't provide a different answer, and would probably be better as an edit or comment to the accepted answer. –  Chip Bennett Dec 11 '12 at 13:14
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.