Ready to get started?Download WordPress


WooCommerce - excelling eCommerce
How to show Private product in woocommerce? (1 post)

  1. Pramod Pandey
    Posted 1 year ago #

    Hello Friends,
    I want to show private product to customer after login & my code is :-

    $query_args = array( 'posts_per_page' => 5, 'post_status' => 'private', 'post_type' => 'product');
      $r = new WP_Query($query_args);
      if ($r->have_posts()) {
        <ul class="product_list_widget">
          <?php while ($r->have_posts()) : $r->the_post(); global $product; ?>
    <li><a>" title="<?php echo esc_attr(get_the_title() ? get_the_title() : get_the_ID()); ?>">
        	<?php if (has_post_thumbnail()) the_post_thumbnail('shop_thumbnail'); else echo '<img src="'. woocommerce_placeholder_img_src() .'" alt="Placeholder" width="'.$woocommerce->get_image_size('shop_thumbnail_image_width').'" height="'.$woocommerce->get_image_size('shop_thumbnail_image_height').'" />'; ?>
        	<?php if ( get_the_title() ) the_title(); else the_ID(); ?>
            </a> <?php echo $product->get_price_html(); ?></li>
          <?php endwhile; ?>
        // Reset the global $the_post as this query will have stomped on it

    [Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum's parser.]

    But it doesn't show any products.
    Plz help me out with this?


Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic


No tags yet.