Wordpress plugins
Fix Featured Sorting for WooCommerce

Fix Featured Sorting for WooCommerce

Version : 0.0.4
Tested up to : 5.1.1
Number of download : 5
Average rating : 0 / 5 on 0 votes 0 votes, 0 avg.rating

Screenshots

Fix Featured Sorting for WooCommerce
Fix Featured Sorting for WooCommerce
Fix Featured Sorting for WooCommerce
Fix Featured Sorting for WooCommerce

Remember when you could sort product by their featured status? Fix Featured Sorting for WooCommerce makes that possible again. Fix Featured Sorting for WooCommerce restores the _featured meta data. This allows you to: Sort the list of products by featured in the admin panel like you were able to before WC 3.1 Use the meta data in your plugin or code snippet to sort the products displayed on the front-end by featured Once the plugin is activated, it will process all of the products and add the _featured meta data to the wp_post_meta table. It will keep this information up-to-date while it is activated. If it is deactivated and later reactivated, it will process all of the products again if a new product was added after deactivation. Sort Products on the Front End By Featured To sort products on the front end by featured, add the following code snippet to your functions.php file or, my preference, Code Snippets: if( !is_admin ) add_action( 'pre_get_posts', 'ltz_pre_get_posts', 999 ); function ltz_pre_get_posts( $query ) { if( !empty($query->query_vars[ 'wc_query' ]) && $query->query_vars[ 'wc_query' ] == 'product_query' && $query->query_vars[ 'orderby' ] == 'menu_order title' ) { $query->set('meta_query', [ 'relation' => 'AND', 'featured' => [ 'key' => 'featured' ], /* 'total_sales' => [ 'key' => 'total_sales' ] */ ]); $query->set('orderby', [ 'featured' => 'DESC', //'total_sales' => 'DESC', 'menu-order' => 'ASC', 'title' => 'ASC', ]); } return $query; } Donations As you may or may not know, web development is expensive. I want to continue to develop useful plugins for everyone to use but in order to do so I need your help. Please support the development of this plugin and my other useful plugins. Your generosity is greatly appreciated; thank you!

Download now