I managed to get the store names of all of the current vendors to display in a <ul> tag but it seems that when I loop to get the products, all of the products registered gets displayed under the store name.
How would I go about getting the products that are unique to the store name?
这是一个WordPress,woocommerce和dokan项目。
用户故事;
作为用户,我将看到供应商的商店名称,并将能够在该供应商的商店名称下方看到该供应商的所有产品。
<div id="dokan-seller-listing-wrap">
<div class="seller-listing-content">
<?php if ( $sellers['users'] ) : ?>
<ul class="dokan-seller-wrap">
<?php
foreach ( $sellers['users'] as $seller ) {
$store_info_author = dokan_get_store_info( $post->post_author );
$store_info = dokan_get_store_info( $seller->ID );
$store_name = isset( $store_info['store_name'] ) ? esc_html( $store_info['store_name'] ) : __( 'N/A', 'dokan-lite' );
$store_url = dokan_get_store_url( $seller->ID );
$featured_seller = get_user_meta( $seller->ID, 'dokan_feature_seller', true );
?>
<div class="row">
<div class="col-md-12">
<div class="store-data">
<h2><a href="<?php echo esc_attr($store_url); ?>"><?php echo esc_html($store_name); ?></a></h2>
</div>
</ul>
<li class="slides">
<?php
$args = array(
'post_type' => 'product',
'posts_per_page' => 12
);
$loop = new WP_Query( $args );
if ($sellers['users']) {
while ( $loop->have_posts() ) : $loop->the_post();
wc_get_template_part( 'content','product' );
endwhile;
} else {
echo __( 'No products found' );
}
wp_reset_postdata();
?>
</li><!--/.products-->
<?php } ?>
</div>
</div>
</div>
</div>
答案 0 :(得分:0)
您需要在 WP_Query 参数中指定 author ,如下所示
@bot.command()
async def afkremoveme(ctx):
#pls help me I'm lost!