WordPress.org

Forums

wp_title destroying numeric character references (3 posts)

  1. huftis
    Member
    Posted 6 years ago #

    I’m having problems with wp_title destroying numeric character references in my post titles. I use the following ‘title’ element:

    <title><?php bloginfo('name'); ?>: <?php wp_title('', true, 'left'); ?></title>

    If the title of my post is written ‘foo bar’, this is converted to ‘Blogname: foo bar’, i.e., the & character is wrongly encoded to &, so that the title of the page (shown in the title bar and in bookmarks) is ‘foo bar’.

    Note that using ‘the_title’ on the main page and post page works fine (& is not converted to &), but this is not appropriate for the XHTML ‘title‘ element, as this can’t contain HTML tags.

  2. huftis
    Member
    Posted 6 years ago #

    Obviously, this forum software also has a similar problem, and double-escaping doesn’t seem to help. I’ll try to explain the problem more closely:

    I use numeric character references (and other HTML stuff) in the title of my post, e.g. the concatenation of ‘foo', an ampersand character, ‘#xa0;bar’. The problem is that this is displayed verbatim by wp_title (but not by the_title), and not as ‘foo’ followed by a hard space followed by ‘bar’. How can I fix this? It really feels more like a bug than a feature.

  3. ganesh_tavva
    Member
    Posted 5 years ago #

    In header.php delete the title code and paste the code for
    <title>
    <?php if(is_page('courses')) { echo "websitename" » courses"; }else if(is_page('solutions')){echo "websitename" » solutions";}
    else {echo "websitename";}
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic