• I use the custom fields to add country flags to my posts so my readers know if the post is for them or not. After upgrading to 2.6 the other day, I noticed that now WordPress is adding a slash in front of any quotation mark. I can go back and edit the slashes out and they don’t come back, but still, I find it kind of weird. Anybody else having their custom fields acting up?

Viewing 10 replies - 16 through 25 (of 25 total)
  • @ Shyzer : I also have the problem with the Save and Publish buttons — they stop working when I try to update a Custom Field after removing one of those erroneous slashes.

    Thread Starter Steven

    (@shyzer)

    So was anybody lucky enough to find a solution to this?

    this happens because wordpress escapes the quote characters ‘ and ” and possibly others using a backslash \, i think this is a security measure but since 2.6 at least the $_POST variables are escaped, sometimes this may not be convenient for development

    you can use php function stripslashes() to remove the escape character
    <?
    echo stripslashes($_POST[‘var’]);
    ?>

    thus something like O\’reilly becomes O’reilly

    i would like to know how to deactivate this issue, it forces to implement an extra call to stripslashes() but that may alter the content in other versions

    –wp-wired

    Thread Starter Steven

    (@shyzer)

    No fix again in 2.6.2 ??

    To avoid the slashes problem I tend to code the <a href="http....."</a> into the theme files and then just add the https://www.domain.com part into the custom field box. That solves the problem.

    I have to say, I had this same problem in WP 2.3 or 2.5 (sorry can’t remember for sure, I think it was 2.5).

    And I use the same Custom Fields GUI plugin mentioned above (even tho it has not been updated since 2007, it still works).

    I don’t have this problem anymore! WP 2.6.1.

    I’m trying to remember what the fix was, or if it just fixed itself. Really, I used to have the exact same problem with slashes, and now I don’t have this problem (just tested again to be sure).

    Thread Starter Steven

    (@shyzer)

    equal, what exactly do you mean? I add images to my custom fields, not anchor links, so I don’t know if that will help everybody.

    When I add custom fields in the write post panel i usually add something like https://www.domain.com/wp-content/uploads/image.jpg. I.e. this code goes in the custom field box on the page iteself.

    Some people I know have chosen to do it so that they would add the following code into their custom field box on the right post section:

    <img src="https://www.domain.com/wp-content/uploads/image.jpg">

    therefore i would include the following in the template file:

    <img src="<?php echo get_post_meta($post->ID, "key", true); ?>

    Got the same problem – as an awful lot of people use custom fields for images and as such should also include quoted alt tags (so changing templates is not much help), I think this counts as a pretty serious problem.
    Been WordPressing from the very beginning and this is the first time I’ve come across something so frustrating.

    Is there any way to upgrade Ticket #7346 to severity: severe?

    Don’t want to sound negative but it seems to have been knocking around, unresolved, for too long. Is there anything else we can do? Work-arounds for something so basic are not really on.

    <?
    echo stripslashes($_POST[‘var’]);
    ?>

    In which file would we insert that piece of code?

Viewing 10 replies - 16 through 25 (of 25 total)
  • The topic ‘Slashes Added To Custom Fields’ is closed to new replies.