• Pramod Pandey

    (@pramodpandey)


    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; ?>
    
        <?php
        // Reset the global $the_post as this query will have stomped on it
        wp_reset_query();
    
      }
    
    	           	?>

    [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?

    http://wordpress.org/extend/plugins/woocommerce/

  • The topic ‘How to show Private product in woocommerce?’ is closed to new replies.