在我的wordpress网站上,我有一个循环。php,一个select标记,其中的选项是通过自定义查询返回的当前类别的帖子。
在更改所选选项时,我有许多javascript函数运行良好,但其中的最后一个函数(函数f\\u next-previous)似乎不起作用。
此功能的目的是在不重新加载页面的情况下更新下一个和上一个链接。
我的模板中与导航链接(下一个和上一个)相关的代码运行良好,如下所示:
<div id="nav-above" class="navigation">
<div class="nav-previous"><?php previous_post_link( \'%link\', \'<img height="34" src="\' . get_bloginfo("template_directory") . \'/images/previous.png" />\' ); ?></div>
<div class="nav-next"><?php next_post_link( \'%link\', \'<img height="34" src="\' . get_bloginfo("template_directory") . \'/images/next.png" />\' ); ?></div>
</div><!-- #nav-above -->
此函数的javascript代码为:function f_next-previous(id)
{
$.ajax({
cache: true,
type: "GET",
timeout: 5000,
url: \'wp-content/themes/twentyten/pages/next-previous.php?p=\'+id,
success: function(msg)
{
$(\'#nav-above\').html(msg);
},
error: function(msg)
{
alert("Your browser broke!");
return false;
}
});
}
下一个上一个文件。php内容为:<?php
$p=$_GET[\'p\'];
require( \'../../../wp-load.php\' );
$my_query = new WP_Query();
$my_query->query(array( \'post__in\' => array($p)));
if ($my_query->have_posts()) : while ($my_query->have_posts()) : $my_query->the_post(); ?>
<div class="nav-previous"><?php previous_post_link( \'%link\', \'<img height="34" src="\' . get_bloginfo("template_directory") . \'/images/previous.png" />\' ); ?></div>
<div class="nav-next"><?php next_post_link( \'%link\', \'<img height="34" src="\' . get_bloginfo("template_directory") . \'/images/next.png" />\' ); ?></div>
<?php
endwhile;
endif;
?>
当通过给这个php文件一个p参数值来测试它时,它会在浏览器中给出逻辑结果。Jquery和函数脚本都包含得很好,我的网站中的所有AJAX都可以。我在这项工作中遗漏了什么????