首页 > 解决方案 > 将帖子插入到查询 wordpress 的末尾

问题描述

我想在archive-property.php中的主查询末尾发送某些带有类别的帖子,例如,我有这样的功能

if(isset($query->query['post_type']) && $query->query['post_type'] == 'property' && !isset($query->query['page'])){
   get_post_type_property($query);
}

而函数 get_post_type_property() 是这样的

function get_post_type_property(&$query){
 $argsExclude = array(
     'post_type' => 'property',
     'orderby' => 'title',
     'order' => 'DESC',
     'tax_query' => array(
        array(
            'taxonomy' => 'property-type',
            'terms' => array('lot', 'lote', 'villa', 'villa-es'),
            'field' => 'slug',
        ),
     ),
 );

 $queryExclude = new WP_Query($argsExclude);

 $propertiesExclude = $queryExclude->posts; // I WANT SEND TO END OF QUERY THIS RESULTS

 $filter_args = array(
     'tax_query'=>array(),
     'meta_query'=>array()
 );

 $query->set( 'posts_per_page', 15 );
 $query->set( 'order', 'ASC' );
 $query->set( 'tax_query', $filter_args['tax_query']);
 $query->set( 'meta_query', $filter_args['meta_query']);
 $meta_query['relation'] = 'AND';
 $meta_query['c_featured_property'] = array(
      'key' => 'c_featured_property',
      'type' => 'NUMERIC',
      'compare' => 'EXISTS'
 );
 $meta_query['c_price'] = array(
      'key' => 'c_price',
      'type' => 'NUMERIC',
      'compare' => 'EXISTS'
 );
 $query->set('meta_query', $meta_query);
 $query->set('orderby', array(
      'c_featured_property' => 'DESC',
      'c_price' => 'DESC'
 ));

这给了我所有结果都很好,但我想将查询 $propertiesExclude 的结果发送到主查询的末尾。

标签: phpwordpress

解决方案


推荐阅读