Woocommerce Featured Products widget (4 posts)

  1. peer_012
    Posted 3 years ago #

    I recently edited Woocommerce's Products On-Sale widget making it display random products marked on-sale by changing the line 'orderby' => 'date', to 'orderby' => 'rand',. Now I want to edit the Featured Products widget to do the same. However, I can't seem to get it to work. I have changed to the code to:

    $query_args['meta_query'][] = array(
    'key' => '_featured',
    'value' => 'yes',
    'orderby' => 'rand'

    but it still does not display random products marked featured. Can anyone please help me out. Thanks in advance!


  2. James Koster
    Plugin Author

    Posted 3 years ago #

    That's because you're modifying the _meta query_.

    In 2.1 you can order the products randomly.

  3. r3plicant3
    Posted 3 years ago #

    I changed the line 84 and worked fine:

    <?php $query_args = array('posts_per_page' => $number, 'no_found_rows' => 1, 'post_status' => 'publish', 'post_type' => 'product', 'orderby' => 'rand');

  4. addesigns
    Posted 2 years ago #

    Just in case anyone stumbles upon b/c they wish to change the Products On-Sale widget to random like I did, here is the file you must edit:


    Search for orderby like peer_012 stated and change 'date' to 'rand'

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WooCommerce
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic