Support » How-To and Troubleshooting » Title of a page outside the loop

Title of a page outside the loop

  • I am trying to accomplish the following outside the loop (in my header, in fact):

    Sub-site name | Page Name

    Simple right? Note that I don’t want the tag line anywhere.

    Here’s what I tried first:

    echo get_bloginfo('name');
    if (!is_front_page()) {
       echo(" | ") . wp_title('', false, '');

    but that outputs:

    Sub-site Name | Page TitleSub-site NameTagline

    I’ve tried using str_replace to remove the superfluous ‘Sub-site TitleTagline’ part of that string, but it’s tricky because wp_title is texturizing the whole thing and get_bloginfo() doesn’t, so… is there an easier way to do this than fiddling with something like htmlentities()?

    I realize that I should probably use the separator argument of wp_title, but that’s also problematice since I actually want that pipe to be
    <span class=\"titledivider\">|</span>
    and wp_title() converts all the code to htmlentities, which is not at all what I want.

Viewing 1 replies (of 1 total)
  • Aha! Twenty Ten applies a filter in its functions.php that makes it NOT behave as defined in the Codex. Getting there…

Viewing 1 replies (of 1 total)
  • The topic ‘Title of a page outside the loop’ is closed to new replies.