Wordpress 获取由插件创建的metabox中的项目

Wordpress 获取由插件创建的metabox中的项目,wordpress,meta-boxes,Wordpress,Meta Boxes,我有一个插件,在那里可以添加团队成员。它实际上是一些成员的名单。 现在我已经为页面创建了一个元数据库。在此元框中,我希望在要选择的选择框中显示这些成员的名称。这样那些成员就会出现在那个页面上。 在metabox代码中,我试图获得如下成员: $post_type2 = 'team'; $orderby2 = 'menu_order'; $order2 = 'ASC'; $posts_per_page2 = 100; $query2 = new WP_Query( a

我有一个插件,在那里可以添加团队成员。它实际上是一些成员的名单。 现在我已经为页面创建了一个元数据库。在此元框中,我希望在要选择的选择框中显示这些成员的名称。这样那些成员就会出现在那个页面上。 在metabox代码中,我试图获得如下成员:

$post_type2 = 'team';
    $orderby2 = 'menu_order';
    $order2 = 'ASC';
    $posts_per_page2 = 100;
    $query2 = new WP_Query( array ( 
        'post_type'      => $post_type2,
        'posts_per_page' => $posts_per_page2,
        'orderby'        => $orderby2, 
        'order'          => $order2,
        'no_found_rows'  => 1
        ) 
    );
    //Get post type count
    $members = array();
    $members2 = array();
    $post_count2 = $query2->post_count;
    if( $post_count2 > 0) :
        while ($query2->have_posts()) :
            $query2->the_post();
            $members2['mid'] = get_the_id();
            $members2['mname'] = get_the_title();
            $members[] = $members2;
            //echo the_id();
        endwhile;
    endif;
但是它把页面本身弄乱了。我可以获取成员,但页面名称已更改为成员名称。我的页面是“主页”,在标题区,它显示了jhon doe-成员名称。知道为什么吗?我认为我使用了错误的“获取”方法来获取项目

编辑 想法:

团队插件添加了一些成员。我想在页面中显示这些成员。但并非所有页面中的成员都相同。例如:“john doe”可以出现在“关于”页面中,但不能出现在“服务”页面中。这样地。这就是为什么我想在页面中创建metabox来选择成员。这样做对吗?或任何其他想法???

在“编辑帖子”管理页面上使用
WP\u Query
是不安全的,因为它会把事情搞砸并导致意外行为。切换到
get_posts
应该可以解决这个问题