admin管理员组文章数量:1130349
I am not able to get the listings to show up. I have verified the slug for the post type and the taxonomy. This code I know works because I have used it for other post types and taxonomy's. Any insight as to why this would not be working here would be appreciated. Thanks.
<?php
$tag = 'commercial_for_lease';
// Set up custom query with meta_query
$args = array (
'post_type' => 'wp-listings', // your property post type slug
'posts_per_page' => 50,
'orderby' => 'rand', // order by
'order' => 'ASC', // Show earlier events first
'tax_query' => array(
array(
'taxonomy' => 'property-types',
'field' => 'slug',
'terms' => array($tag)
))
);
$query = new WP_Query( $args );
if ( $query->have_posts() ) :
while ( $query->have_posts() ) : $query->the_post(); ?>
<div class="col-md-4" id="<?php echo get_the_id(); ?>">
<div class="row">
<a href="<?php the_permalink(); ?>">
<div class="item-container">
<div class="item-container-img">
<?php the_post_thumbnail(); ?>
</div>
<div class="item-container-text">
<h4><?php the_title(); ?><h4>
<h5><?php echo get_post_meta( get_the_ID(),'listing-price', true); ?></h5>
</div>
</div>
</a>
</div>
</div>
<?php endwhile; wp_reset_query(); ?>
<?php wp_reset_postdata();
endif;
?>
I am not able to get the listings to show up. I have verified the slug for the post type and the taxonomy. This code I know works because I have used it for other post types and taxonomy's. Any insight as to why this would not be working here would be appreciated. Thanks.
<?php
$tag = 'commercial_for_lease';
// Set up custom query with meta_query
$args = array (
'post_type' => 'wp-listings', // your property post type slug
'posts_per_page' => 50,
'orderby' => 'rand', // order by
'order' => 'ASC', // Show earlier events first
'tax_query' => array(
array(
'taxonomy' => 'property-types',
'field' => 'slug',
'terms' => array($tag)
))
);
$query = new WP_Query( $args );
if ( $query->have_posts() ) :
while ( $query->have_posts() ) : $query->the_post(); ?>
<div class="col-md-4" id="<?php echo get_the_id(); ?>">
<div class="row">
<a href="<?php the_permalink(); ?>">
<div class="item-container">
<div class="item-container-img">
<?php the_post_thumbnail(); ?>
</div>
<div class="item-container-text">
<h4><?php the_title(); ?><h4>
<h5><?php echo get_post_meta( get_the_ID(),'listing-price', true); ?></h5>
</div>
</div>
</a>
</div>
</div>
<?php endwhile; wp_reset_query(); ?>
<?php wp_reset_postdata();
endif;
?>
Share
Improve this question
asked Dec 7, 2018 at 22:52
StrattonStratton
111 bronze badge
1 Answer
Reset to default 1I suggest starting your query by first only passing the post_type and posts_per_page arguments. This will let you know if you're getting the right entries and if so then begin to use your filters (orderby, order, etc).
I am not able to get the listings to show up. I have verified the slug for the post type and the taxonomy. This code I know works because I have used it for other post types and taxonomy's. Any insight as to why this would not be working here would be appreciated. Thanks.
<?php
$tag = 'commercial_for_lease';
// Set up custom query with meta_query
$args = array (
'post_type' => 'wp-listings', // your property post type slug
'posts_per_page' => 50,
'orderby' => 'rand', // order by
'order' => 'ASC', // Show earlier events first
'tax_query' => array(
array(
'taxonomy' => 'property-types',
'field' => 'slug',
'terms' => array($tag)
))
);
$query = new WP_Query( $args );
if ( $query->have_posts() ) :
while ( $query->have_posts() ) : $query->the_post(); ?>
<div class="col-md-4" id="<?php echo get_the_id(); ?>">
<div class="row">
<a href="<?php the_permalink(); ?>">
<div class="item-container">
<div class="item-container-img">
<?php the_post_thumbnail(); ?>
</div>
<div class="item-container-text">
<h4><?php the_title(); ?><h4>
<h5><?php echo get_post_meta( get_the_ID(),'listing-price', true); ?></h5>
</div>
</div>
</a>
</div>
</div>
<?php endwhile; wp_reset_query(); ?>
<?php wp_reset_postdata();
endif;
?>
I am not able to get the listings to show up. I have verified the slug for the post type and the taxonomy. This code I know works because I have used it for other post types and taxonomy's. Any insight as to why this would not be working here would be appreciated. Thanks.
<?php
$tag = 'commercial_for_lease';
// Set up custom query with meta_query
$args = array (
'post_type' => 'wp-listings', // your property post type slug
'posts_per_page' => 50,
'orderby' => 'rand', // order by
'order' => 'ASC', // Show earlier events first
'tax_query' => array(
array(
'taxonomy' => 'property-types',
'field' => 'slug',
'terms' => array($tag)
))
);
$query = new WP_Query( $args );
if ( $query->have_posts() ) :
while ( $query->have_posts() ) : $query->the_post(); ?>
<div class="col-md-4" id="<?php echo get_the_id(); ?>">
<div class="row">
<a href="<?php the_permalink(); ?>">
<div class="item-container">
<div class="item-container-img">
<?php the_post_thumbnail(); ?>
</div>
<div class="item-container-text">
<h4><?php the_title(); ?><h4>
<h5><?php echo get_post_meta( get_the_ID(),'listing-price', true); ?></h5>
</div>
</div>
</a>
</div>
</div>
<?php endwhile; wp_reset_query(); ?>
<?php wp_reset_postdata();
endif;
?>
Share
Improve this question
asked Dec 7, 2018 at 22:52
StrattonStratton
111 bronze badge
1 Answer
Reset to default 1I suggest starting your query by first only passing the post_type and posts_per_page arguments. This will let you know if you're getting the right entries and if so then begin to use your filters (orderby, order, etc).
本文标签: custom post typesShow listings from Impress Listing plugin in random order using taxonomy and terms
版权声明:本文标题:custom post types - Show listings from Impress Listing plugin in random order using taxonomy and terms 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749108552a2316985.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论