Php WP\u安装程序内部查询\u postdata()
我需要使用Php WP\u安装程序内部查询\u postdata(),php,wordpress,Php,Wordpress,我需要使用setup\u postdata() 然而,X的页面有两个WP\u查询,当单独查看该页面时,这两个查询工作得非常好。但是当访问Y的页面时,wp查询后的内容会变得混乱 我知道这是因为我的wp\u reset\u postdata()正在重置setup\u postdata()循环 是否可以在不反映外部setup\u postdata()循环的情况下重置查询 X的页面 <?php get_header(); $the_slug = 'work-with-us'; $args = ar
setup\u postdata()
然而,X的页面有两个WP\u查询
,当单独查看该页面时,这两个查询工作得非常好。但是当访问Y的页面时,wp查询后的内容会变得混乱
我知道这是因为我的wp\u reset\u postdata()
正在重置setup\u postdata()
循环
是否可以在不反映外部setup\u postdata()
循环的情况下重置查询
X的页面
<?php
get_header();
$the_slug = 'work-with-us';
$args = array('name' => $the_slug,
'post_type' => 'page',
'post_status' => 'publish',
'numberposts' => 1);
$my_posts = get_posts($args);
global $post;
$post = $my_posts[0];
setup_postdata( $post );
include 'inc-work-with-us.php';
wp_reset_postdata();
get_footer();
?>
Y的页面查询
<?php
$args = array(
'post_type' => 'positions',
'orderby' => 'title',
);
$location_loop = new WP_Query($args);
if($location_loop->have_posts()) :
while($location_loop->have_posts()) : $location_loop->the_post();
echo 'hey';
endwhile;
endif;
wp_reset_query();
?>