• To change my titles to show my post title first and my blog title second I used the WordPress Codex code:

    <title>
     <?php wp_title('|',true,'right'); ?>
     <?php bloginfo('name'); ?>
     </title>

    Which worked fine except for one thing. When I replaced the pipe with a hyphen:
    <?php wp_title('-',true,'right'); ?>

    the hyphen showed up as “–”

    Am working offline on it with MAMP (which I love) so haven’t included URL.

    Can’t find answer anywhere. Can anyone help?

Viewing 9 replies - 1 through 9 (of 9 total)
  • the hyphen showed up as “–”

    Isn’t that how a hyphen is supposed to look?
    *confused*

    Thread Starter saphire3

    (@saphire3)

    How weird. The hyphen showed up fine in my above question, but on the source page of my offline site it showed up as:
    & # 8 2 1 1 ; (minus the extra spaces)

    Are you sure that you didn’t accidentally enter an elongated hyphen as opposed to a minus sign?

    Thread Starter saphire3

    (@saphire3)

    No, I copied and pasted from there to here. And here for some odd reason, the hyphen showed up fine. Even when I pasted those weird characters into my title question, they turned into a hyphen too.

    Just noticed that the code has single quotes around it, but here I used double quotes around the strange characters. Could that have something to do with it?

    Yes – it could do.

    Thread Starter saphire3

    (@saphire3)

    Nope, just tried the double quotes and the line still comes up as:

    <title>
    test 22

    Savvy Saving Bytes </title>

    Thread Starter saphire3

    (@saphire3)

    Unbelieveable. It turned into a hyphen again. What I just typed was:
    & # 8 2 1 1 ; (minus the extra spaces) between the two titles.

    I need a dinner break here (at least).

    My bad! I’ve just tested this on Twenty eleven and it does look like a filter is being run on wp_title() to convert a standard minus sigh into an elongated hyphen. A quick but inelegant fix is to use wp_title( '-', true, 'right' ); but ideally, you shouldo check through core to see what the filter is and remove it via your theme’s functions.php file.

    Thread Starter saphire3

    (@saphire3)

    I’m afraid that fix didn’t fix the problem. Had the same result as before. Well, at least the pipe works so I’ll use that till I can find the answer.

    As far as:
    “Ideally, you shouldo check through core to see what the filter is and remove it via your theme’s functions.php file…”

    That’s a whole other realm to me and I’ve got plenty of other realms to play around with now…

    But thanks very much for your help anyway.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘php hyphen is printing as "–"’ is closed to new replies.