Wordpress WP_通过jquery加载进行查询
我通过jquery加载一个php文件,它应该加载一个新的WP_查询, 但是WP负载不起作用,下面是我的代码: jquery代码:Wordpress WP_通过jquery加载进行查询,jquery,wordpress,include,load,Jquery,Wordpress,Include,Load,我通过jquery加载一个php文件,它应该加载一个新的WP_查询, 但是WP负载不起作用,下面是我的代码: jquery代码: $('.teaser-click').click(function(){ var post_id = $(this).attr("rel"); $("#content-"+post_id).load("xxxMYURLxxx/load-content.php", {neuId:post_id}); }); load-content.php $neuId = $_
$('.teaser-click').click(function(){
var post_id = $(this).attr("rel");
$("#content-"+post_id).load("xxxMYURLxxx/load-content.php", {neuId:post_id});
});
load-content.php
$neuId = $_POST['neuId'];
echo "neuId: ".$neuId;
很好,直到我拿到正确的身份证,
身份证也会出现在分区里但我不会
wp查询的内容
我还尝试了'p'=>200(仅用于测试)
$args=array(
'p'=>$neuId,
“post_type”=>“any”,
);
$my_new_posts=新的WP_查询($args);
while($my_new_posts->have_posts()):$my_new_posts->the_post()?>
下面是索引文件的wp查询
if (have_posts()) :
while (have_posts()) : the_post();
...
<?php endwhile; ?>
<?php endif; ?>
if(have_posts()):
while(have_posts()):the_post();
...
非常感谢,您是否在php文件加载内容中包含定义WP_查询的文件 请发送整个加载内容的php文件 您尝试添加了吗
require_once(ABSPATH . 'wp-load.php');
或者,如果ABSPATH不起作用,您可能希望尝试手动使用.././并转到路径 罗伯特·李的答案是实现这一点。是的,那是个错误!这里的代码为我工作!定义('WP_使用_主题',false);require_once('PATHHERE/wp blog header.php');
require_once(ABSPATH . 'wp-load.php');