• Resolved GregW

    (@gwmbox)


    I am having an issue with a website where WordPress is using code like &#8211 instead of using a dash in the title and other places. The same issue exist for a ‘

    So I have tested on a brand new install of WordPress 5.8.2.

    No plugins or themes have been installed.

    No content added, it is a barebones new WP install.

    Is this usual? Is there a way for it to not use the code format?

Viewing 15 replies - 1 through 15 (of 21 total)
  • Moderator bcworkz

    (@bcworkz)

    I cannot replicate such behavior on my similar no plugins, default theme site.

    Did you copy/paste the title from elsewhere? If the source contained the entity code, the WP editor will not convert entity codes to respective characters in titles. Instead only the initial & is encoded, making the remaining #8211; ineffective as entity code.

    If you were to enter or paste in the actual character, it should remain that way. The only way I get the behavior you describe on my site is if I literally type in & # 8 2 1 1 ; (without the spaces).

    Thread Starter GregW

    (@gwmbox)

    No, just typed it in when it was installed and it still has the default tagline.

    So my title is (I have removed the ; as it will render as the dash on here)

    <title>WordPress Test Site &#8211 Just another WordPress site</title>

    It has to be something related to my VPS setup then, as when I add content on a new page with a dash an apostrophe, it shows it as code when viewing the page source.

    Does anyone know what I need to check and turn on/off to fix?

    • This reply was modified 2 years, 11 months ago by GregW.
    Moderator bcworkz

    (@bcworkz)

    OK, if you actually type in the entity code as a title, WP will display the title exactly as you typed — the entity code instead of the n-dash it’s supposed to represent. To get an n-dash in a title, you actually have to type (or paste) in the n-dash character. This is normal WP behavior. Nothing wrong with your VPS.

    If your keyboard cannot generate an n-dash character through keypress, you’ll need to copy/paste it from elsewhere, like a word processor where you can pick special characters from a grid.

    Thread Starter GregW

    (@gwmbox)

    But I am not and cannot add that dash, it is auto created by WordPress.

    For example Page Title – Website Title

    The – between them is created by WordPress not me entering anything.

    The result is Page Title &#8211 Website Title

    Same with the site title

    Site Title – Just another WordPress site

    Where again I do not add the dash, it is inserted by WordPress

    Result is still

    Site Title &#8211 Just another WordPress site

    The same thing happens for a dash and apostrophes in the content, possibly other punctuation etc I have not yet tested

    On more testing, it is only the dash, underscore and apostrophe that appear to be having an issue

    • This reply was modified 2 years, 11 months ago by GregW.
    • This reply was modified 2 years, 11 months ago by GregW.
    Moderator bcworkz

    (@bcworkz)

    Oh, that title! Sorry for my being dense.

    The page’s charset meta tag is “UTF-8”, isn’t it?

    That dash should get entity encoded into the proper &.#8211; (without the dot), but then your browser should automatically decode it back to . It sounds like some added filter is causing this to be double encoded.

    Viewing the page’s source HTML, what does the title meta tag have for a value? You’ll have to insert dots or something into any entity codes before sharing here. I think you may be getting something like Site Title &.amp;#8211; Just another WordPress Site, which would cause the output you’re seeing.

    But there shouldn’t be any added filter in a default WP installation with no plugins. That’s essentially my site as well, and I cannot replicate the problem you’re having. Does your site have a /wp-content/mu-plugins/ folder which contains any files or sub-folders? Any code there could be causing double encoding. The code there can be disabled as a test by renaming /mu-plugins/.

    • This reply was modified 2 years, 11 months ago by bcworkz.

    Hi guys

    I’m also having the same issue.
    I’m trying to make a custom API with register_rest_route() and some CPT (with CPT-UI Plugin) and, in the title of the post, if I put a “-” (hyphen) it shows a— (m-dash!) in the JSON. And shows – (n-dash!) (no mistake typing!) in the view source of the rendered Post.

    While we’re at encoding, let me say it’s getting very dificcult to come up with a solution to clean all the html comments from the body text. I searched everywhere, tried every encoding, striping, and none is perfect.
    The best, so far, was to put wp_strip_all_tags() in get_the_content() and show_in_Rest = false (which sounds weird) in the CPT Plugin options.

    But I’m sure there is a better solution for this.. (I hope)

    I have the same issue with Zapier + WordPress, if a title contains a punctuation sign, it will be transformed into an HTML code. Contacted Zapier support and they said it’s a WordPress issue

    When I write titles in wordpress with a dash (-) between my brand name and a few lines about it then its shows this &#8211 instead of dash sign.

    for example:
    newwebsite – my new business website

    but its shows like
    newwebsite &#8211 my new business website

    Please help in this regard. Please its a humble request.

    Thread Starter GregW

    (@gwmbox)

    Yes it is still an ongoing issue.

    MJuguet

    (@mjuguet)

    Hi there,

    I encountered the same issue when trying to add dash “-” into my titles (replaced automatically by code &#8211) and i found a solution :

    (All the codes will be written without semicolon at the end to prevent from automatic formating, so don’t forget to add ; at the end of the code &#8211 when you try this solution).

    – Instead of typing – into your title input in the wordpress interface, type the code &#8211
    – Then, update the website once to let the wordpress editor format the code to create a hyphen into the title input (hyphen is just a little bit bigger than simple dash)
    – Finally, update website a second time to put this hyphen into the web page
    – Check your web page to see if it works well

    Best regards.

    • This reply was modified 2 years ago by MJuguet.
    • This reply was modified 2 years ago by MJuguet.

    Hi guys, I was facing the same issue and the below solution worked for me.

    -In my case we were using Laravel framework from backend and the title was passed through PHP as {{ $data }}.
    -On passing the title as {!! $data !!} the bug (&#8211 instead of using a dash ) was fixed.

    Explaination : https://stackoverflow.com/questions/35030977/what-is-the-difference-between-and-in-laravel-blade-files

    I have the same error and I can’t solve it in any way

    Hello everyone,
    these characters are created by WordPress itself through the function wptexturize . This function is called is several places, for example, when rendering:

    • the post title: see here
    • the post content: see here

    and several other places you can find by searching for wptexturize in the WordPress code.

    To solve the issue you can use the run_wptexturize filter or use a remove_filter call, for example:
    remove_filter( 'the_title', 'wptexturize' );

    Hope this helps solve your issue.

    Thanks a lot @gmosso

    Thread Starter GregW

    (@gwmbox)

    @ridesirat What did you add to your functions.php file?

    I used remove_filter( ‘the_title’, ‘wptexturize’ );

    but this did not fix it. I still have both (removed ; to show code and not dash)

    &#x2d and &#8211

    Does this also meant to work in the title metas like og and twitter titles

    • This reply was modified 1 year, 4 months ago by GregW.
    • This reply was modified 1 year, 4 months ago by GregW.
    • This reply was modified 1 year, 4 months ago by GregW.
    • This reply was modified 1 year, 4 months ago by GregW.
Viewing 15 replies - 1 through 15 (of 21 total)
  • The topic ‘&#8211 is in TITLE instead of a Dash’ is closed to new replies.