views:

24

answers:

2

I'm helping a friend with a custom WordPress theme she purchased from Theme Forest that has a jQuery slideshow using the cycle plugin. It works just fine on all the Pages. I looked at the code and the only thing I can figure out is that on the blog pages it processes the code incorrectly by adding a backslash in front of all the " and ' characters, which breaks it in the javascript. I'm not sure where to begin to fix this. Both the page.php and the single.php file reference the following code:

    <div id="slide">
    <?php 
        if ( get_post_meta($post->ID,'head', true) ) { 
            echo get_post_meta($post->ID,'head', true);
        } elseif ( get_post_meta($post->post_parent,'head', true) ) {
                echo get_post_meta($post->post_parent,'head', true);
        } else { 
            echo get_option('retro_headimage');
        }           
    ?>
    </div>
    <script type="text/javascript">
        $('#slide').cycle('fade');
    </script>

Which is outputted like:

<div id="slide">
<img src="/wp-content/uploads/2009/11/over-the-hill.jpg" alt="" />
</div>
<script type="text/javascript">
$('#slide').cycle('fade');
</script>

On the post pages that don't have the post_meta of 'head' set, this is the outputted html:

<div id="slide">
<img src=\"/wp-content/uploads/2009/11/over-the-hill.jpg\" alt=\"\" />
</div>
<script type="text/javascript">
$('#slide').cycle('fade');
</script>

Which breaks the javascript. So I noticed that it was echoing an option of 'retro_headimage' which is set in the Theme Options page in the dashboard. The problem is, anytime you go into that Theme Options page and re-enter the correct code for the image upon saving it the backslashes reappear. Can anybody help?

+1  A: 

I have not worked on PHP but it looks like the Theme Options page calls add_option/update_option (http://codex.wordpress.org/Function_Reference/add_option) which will escape the value being set. You need to see if there is a way to set the value without escaping the quotes.

Thought it is not the final answer, hope it points you in the right direction.

Prem
A: 

I've answered my own question and it was SIMPLE! Instead of going thru custom theme admin pages and editing functions and figuring out how to set values without escaping quotes, I just edited the first file above, and changed the "echo get_option('retro_headimage');" section to echo a basic image tag. Problem solved! :)

RodeoRamsey