import - update_post_meta 属性可见性?
问题描述
我正在尝试查找如何显示导入的属性列表。问题是元数据,导入后属性在前端不可见,我需要手动更新每个项目。如何更新元数据编辑以下代码:
<?php
$args = array(
'posts_per_page' => $custom_property_items_amount,
'post_type' => 'property',
'orderby' => array(
'menu_order'=>'ASC',
'date' =>'DESC',
),
'offset' => ( max( 1, get_query_var( 'paged' ) ) - 1 ) * $custom_property_items_amount,
'ignore_sticky_posts' => 1,
'post_status' => array('publish','pending','draft','future','private'),
);
$data = new WP_Query( $args );
?>
<div class="<?php echo join( ' ', $wrapper_classes ) ?>">
<?php if ( $data->have_posts() ) :
while ( $data->have_posts() ): $data->the_post(); ?>
<?php ere_get_template( 'content-property.php', array(
'custom_property_image_size' => $custom_property_image_size,
'property_item_class' => $property_item_class
)); ?>
<?php endwhile;
else: ?>
<div class="item-not-found"><?php esc_html_e( 'Not found', 'essential-real-estate' ); ?></div>
<?php endif; ?>
<div class="clearfix"></div>
<?php
$max_num_pages = $data->max_num_pages;
ere_get_template( 'global/pagination.php', array( 'max_num_pages' => $max_num_pages ) );
wp_reset_postdata(); ?>
</div>
解决方案
解决了!问题出在这部分代码中:
if (!empty($features)) {
foreach($features as $feature){
$tax_query[] = array(
'taxonomy' => 'property-feature',
'field' => 'slug',
'terms' => $feature
);
$parameters.=sprintf( __('Feature: <strong>%s</strong>; ', 'essential-real-estate'), $feature);
}
}
$args['meta_query'] = array(
'relation' => 'AND',
$meta_query
);
$tax_count = count($tax_query);
if ($tax_count > 0) {
$args['tax_query'] = array(
'relation' => 'AND',
$tax_query
);
}
通过删除它,所有项目都显示出来了。
推荐阅读
- odoo - Odoo 14 longpolling bus.Bus 在 GKE Ingress 后面运行不可用
- java - 需要将端口号从原始端口号更改为另一个端口号?
- spring-boot - 需要了解 Spring WebClient 的异步使用
- admin - 如何设置 splunk 独立环境
- python - 如何通过 web 使用 python 在我的服务器中共享文件
- php - 尝试访问索引时出现错误#404
- arrays - 如何按照以下代码示例将指针函数 abc(x, y) 存储到数组中?
- hive - HIVE分区查询
- php - 由于我正在使用 MAMP 的本地托管,但“此网站出现严重错误”,这是错误即将到来。我应该怎么办?
- android - 在 Android 10 内核上使用 Linux 应用程序发送数据包失败