Forums

[resolved] Escape character inserted in custom fields (9 posts)

  1. poodlerat
    Member
    Posted 4 years ago #

    When I type a single quote (') in a custom field, WordPress escapes it with a backslash (\). That backslash shows up when I display custom fields for my posts. Is there an easy way to get rid of this?

    Thanks!

  2. syncbox
    Member
    Posted 4 years ago #

    Why are you using the single quote? Try using a character entity for it if all you want is 'something like this'

    the character entity to use is for an apostrophe. If you want matching opening and closing ones, the left side one is

    otherwise, put the \ in before the single quotes you use yourself and see what happens.

    HTH

  3. poodlerat
    Member
    Posted 4 years ago #

    Thanks, but I really don't see using curly quotes as a long-term solution. I want to be able to type a regular apostrophe (using the apostrophe key on my keyboard) without having to escape it. But the real problem is that when I do escape the apostrophe, the escape character shows up in the front end of WordPress!

    I know I can use character entities like ’ and ” as apostrophes and single and double quotes, but I don't feel like I should have to.

  4. poodlerat
    Member
    Posted 4 years ago #

    Okay, I realized that if I want to type ordinary quotes (") and apostrophes (') in custom fields, I just have to use stripslashes() when retrieving the data. (Because of the way I had my Write Post page set up, it took me a long time to realize this. Also, this only works if the text is entered in a textarea field rather than an input field.)

    If anyone else has this problem, I hope that helps!

  5. timothyb
    Member
    Posted 3 years ago #

    I'm having the same issue in WP 2.6...

    When I try to insert this into a custom field so the image shows up on a page:

    <img src="http://www.bestgreenblogs.com/images/star30.gif"><img src="http://www.bestgreenblogs.com/images/supporter.png" border="0" title="This blogger donated to keep the independent green blogosphere alive!">

    It shows up like this:
    <img src=\"http://www.bestgreenblogs.com/images/star30.gif\"><img src=\"http://www.bestgreenblogs.com/images/supporter.png\" border=\"0\" title=\"This blogger donated to keep the independent green blogosphere alive!\">

    What do I do to make that not happen?

  6. alfaguru
    Member
    Posted 3 years ago #

    This is definitely a bug in WP 2.6. There is an easy workaround, however, since it only occurs on an add operation. If you re-edit the field and press update - voila - no escapes.

  7. timothyb
    Member
    Posted 3 years ago #

    Ugh pain in the bum. Can this be fixed in the next update?

  8. Niemi
    Member
    Posted 3 years ago #

    I just created a blog and I have the excact same problem.

    I started a thread on opendesigns so if you haven't found a solution keep an eye on that one.

    No-one found a fix for this yet?

  9. markchicobaby
    Member
    Posted 3 years ago #

    Not sure if this is old news, but I couldn't find the answer so I've documented how to fix it on my (brand spanking new) blog

    how to fix wordpress double apostrophe problem
    http://www.markchicobaby.com/?p=5

    You need to set magic_quotes_gpc Off but if you're running PHPsuexec then you need to follow my instructions. Hope it works for you.

    M

Topic Closed

This topic has been closed to new replies.

About this Topic