我正在幫助朋友使用從主題森林購買的自定義WordPress主題,該主題具有使用循環插件的jQuery幻燈片。它適用於所有頁面。我查看了代碼,唯一能找到的就是在博客頁面上,它通過在所有「和」字符前添加一個反斜槓來錯誤地處理代碼,這會在javascript中打破它。我不確定從哪裏開始解決這個問題無論是page.php文件和文件single.php中參考下面的代碼:jQuery幻燈片循環插件反斜槓錯誤
<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'選項。問題是,無論何時進入該主題選項頁面並在保存圖像時重新輸入正確的代碼,反斜槓都會重新出現。任何人都可以幫忙嗎?
我已經回答了我自己的問題。 (我能做到嗎?)我想,我可以解決這個問題,而無需自定義編碼PHP的東西,並逃脫東西?簡單!我剛剛編輯了上面的第一個文件,並更改了「echo get_option('retro_headimage');」部分回顯一個基本的圖像標籤。問題解決了! :) – RodeoRamsey 2010-08-12 14:53:36