Support » Fixing WordPress » En dash not displaying in title tag using conditional tags

  • Hi there

    The en dash is displaying as – in my title when I switch the title with conditional tags to get more information. I have tried replacing the – with – but I still get the same problem. I can’t post a link as working locally sorry but here is the example code:

    if(is_home()) {
    echo bloginfo(‘name’).’ ’ Home’;
    } elseif(is_category()) {
    echo ‘Browsing the Category ‘;
    wp_title(‘ ‘, true, ”);
    } elseif(is_archive()){
    echo ‘Browsing Archives of’;
    wp_title(‘ ‘, true, ”);
    } elseif(is_search()) {
    echo ‘Search Results for “‘.$s.'”‘;
    } elseif(is_404()) {
    echo ‘404 – Page got lost!’;
    } else {
    bloginfo(ënameí); wp_title(‘-‘, true, ”);

    and here is what the title looks like:

    <title>rockstar – testing, one two three.</title>

    Can anyone shed some light on why this is happening? I use MAMP.

    Thanks so much in advance – a reply would be much appreciated, have posted around 6 questions in the past 7 or so months and not one post has been answered! I managed to solve or do work arounds for all questions but only after HOURS of research.

Viewing 6 replies - 1 through 6 (of 6 total)
  • esmi


    Forum Moderator

    Try using wp_title('ndash;', true, '')

    Thanks so much for answering my question. I have tried that and it didn’t work. What is strange is the the en dash displays fine on the home page.

    I haven noticed the code I posted has some of the actual en dashes missing by mistake. I must have copied the code I was playing around with. The actual code does have the end dashes in the code for the title, archives and home. Is there a way to edit a post so I can fix this? Can see any edit buttons for older posts.



    Forum Moderator

    Try using & #150; or & #8211 (removing the spaces between & and # – which I had to add to circumvent the forum’s auto formatting)

    Thanks once again for taking the time to answer but unfortunately those options don’t work either. I wonder if it is a bug? Is anyone else having this problem?

    Ok I have done some more testing and this is happening on all my websites. Unfortunately I don’t have any live yet so can’t provide links.

    It is only happening on post pages, not pages and I always set permalinks set to custom, /%category%/%postname%/ due to SEO.

    There is a change I am doing something wrong but can’t see what. Please can someone help me out with this?


    Hi. Can someone please help me out with this please? I am not sure how to get help on these forums from a moderator but I would really like some help or even just confirmation that this is a bug or not so I don’t waste even more hours (yes, hours!) trying to figure out what I am doing wrong.

    I have just had a look at another website (live, not mine) and it appears to have the same problem: so to me it looks like a bug.


Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘En dash not displaying in title tag using conditional tags’ is closed to new replies.