带有jquery .load()的wordpress循环
|
我有一个带标签的侧边栏小部件,用于显示我的“热门文章,最近的文章”
有2个独立的循环。
我想在其上实现一些Ajax,因此我创建了一个名为last-articles.php的新文件,并粘贴了最新文章循环
<?php $recent = new WP_Query(\"cat=23,4&showposts=8\"); while($recent->have_posts()) : $recent->the_post();?>
<a href=\"<?php the_permalink(); ?>\">
<h2><?php the_title(); ?></h2></a>
<h3> <?php the_category(); ?> </h3>
<?php endwhile; ?>
在我的header.php文件中
<script type=\"text/JavaScript\">
$(document).ready(function(){
$(\"#latestArticles\").click(function(){
$(\"#tab2\").load(\"<?php bloginfo(\'template_directory\'); ?>/recent-articles.php\");
});
});
</script>
\“ latestArticles \”是选项卡按钮的ID
\“ tab2 \”是显示我的循环的div容器的ID
每当我尝试时,都会出现此错误
Fatal error: Class \'WP_Query\' not found in C:\\AppServ\\www\\wordpress\\wp-content\\themes\\mytheme\\recent-articles.php on line 1
谁能帮忙??
没有找到相关结果
已邀请:
1 个回复
吠强祷豪硅