0

我正在帮助一位朋友使用她从 Theme Forest 购买的自定义 WordPress 主题,该主题具有使用循环插件的 jQuery 幻灯片。它适用于所有页面。我查看了代码,我唯一能弄清楚的是,在博客页面上,它通过在所有 " 和 ' 字符前面添加反斜杠来错误地处理代码,这会在 javascript 中破坏它。我不确定从哪里开始解决这个问题。page.php 和 single.php 文件都引用了以下代码:

    <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>

输出如下:

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

在没有设置'head'的post_meta的帖子页面上,这是输出的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>

这打破了javascript。所以我注意到它正在呼应在仪表板的“主题选项”页面中设置的“retro_headimage”选项。问题是,只要您进入该主题选项页面并在保存图像后重新输入正确的图像代码,反斜杠就会重新出现。有人可以帮忙吗?

4

2 回答 2

1

我没有使用过 PHP,但看起来主题选项页面调用 add_option/update_option ( http://codex.wordpress.org/Function_Reference/add_option ) 将转义设置的值。您需要查看是否有一种方法可以在不转义引号的情况下设置值。

认为这不是最终答案,希望它为您指明正确的方向。

于 2010-08-12T05:09:01.177 回答
0

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! :)

于 2010-08-12T14:56:09.267 回答