4

I'm using the Option API for my theme settings page. I use the $_POST data to update the options when the changes are saved. My issue is that the strings I send get escaped and when I use this code:

<?php echo get_option('myOption'); ?>

it echoes the escaped string.

So for example, say 'myOption' = Bob's Diner

Using the above statement, it echoes Bob\'s Diner, which is definitely not what I want.

How exactly do I go about removing that backslash when I call the option on the site?

1

1 Answer 1

5

You can use PHP's stripslashes() command:

<?php echo stripslashes( get_option( 'myOption' ) );
2
  • Oh wasn't aware of that function exists. Sweet that worked. Thank you sir!
    – FranticJ3
    Jul 9, 2014 at 17:21
  • @FranticJ3 if this answer solved your problem, then mark this answer as accepted. Jul 9, 2014 at 23:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.