WordPress.org

Ready to get started?Download WordPress

Forums

php hyphen is printing as "–" (10 posts)

  1. saphire3
    Member
    Posted 2 years ago #

    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?

  2. esmi
    Forum Moderator
    Posted 2 years ago #

    the hyphen showed up as "–"

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

  3. saphire3
    Member
    Posted 2 years ago #

    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)

  4. esmi
    Forum Moderator
    Posted 2 years ago #

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

  5. saphire3
    Member
    Posted 2 years ago #

    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?

  6. esmi
    Forum Moderator
    Posted 2 years ago #

    Yes - it could do.

  7. saphire3
    Member
    Posted 2 years ago #

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

    <title>
    test 22

    Savvy Saving Bytes </title>

  8. saphire3
    Member
    Posted 2 years ago #

    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).

  9. esmi
    Forum Moderator
    Posted 2 years ago #

    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.

  10. saphire3
    Member
    Posted 2 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic