Home Forums Theme Support Dokan Random products

This topic is: resolved

This topic contains 3 replies, has 2 voices, and was last updated by  Sk 5 years ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #20336

    Artem
    Member
    Post count: 24

    I do child theme. Want to add into front page random products (like products archive page):

    
    	<!-- RANDOM PRODUCTS -->
    
    	<ul class="products">
    	<?php query_posts('post_type=product&post_status=publish&orderby=rand'); ?>
    
    	<?php while (have_posts()) : the_post(); ?>
    
    		<?php wc_get_template_part( 'content', 'product' ); ?>
    
    	<?php endwhile; ?>
    	</ul>
    
    	<!-- RANDOM PRODUCTS -->
    

    This code working. On archive products page all correct (in lines of four products and correct styles). But on front page output is not correct (I think, that some styles needed). What need to add for correct output everywhere?

    #20338

    Sk
    Moderator
    Post count: 371

    hello Artem,

    use this query please. it should work.

    <?php $args = array(
            'post_type'             => 'product',
            'post_status'           => 'publish',
            'orderby'               => 'rand'
        );
     $dokan_product_query = new WP_Query( apply_filters( 'dokan_random_product_query', $args ) ); ?>
    
    <?php while ( $dokan_product_query->have_posts() ) : $dokan_product_query->the_post(); ?>
           <?php wc_get_template_part( 'content', 'product' ); ?>
    <?php endwhile; ?>
    

    thank you

    #20340

    Artem
    Member
    Post count: 24

    Ok, but problem not in this.

    How I can output query results (random products) in front page with styles from archive page? Style <ul class="products"> not working on front page… and output without correct styles.

    #20346

    Sk
    Moderator
    Post count: 371

    ok, edit your child themes css file for style. it will overwrite main styles.

    if you are not good in css please hire an expert

    thank you.

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Random products’ is closed to new replies.