• Skip to main content
  • Skip to primary sidebar
  • Business
  • WordPress
  • Security
  • Marketing
  • Publicity
  • Computing
  • Resources
  • Whatevs

Purely Wordpress

Just The Tech, News, and Info We Deem To Post

  • Home
  • About
  • Contact
  • Contribute
You are here: Home / Code Snippets / Add Sort Order to WooCommerce Page Attributes

Add Sort Order to WooCommerce Page Attributes

Screenshot of WordPress plugin php and html code

Add the following code to your theme’s function.php file, or a functionality plugin to add Sort Order to WooCommerce Page Attributes.

/** Sort products by menu order ********/

function be_products_query( $query ) {
	if( $query->is_main_query() && !is_admin() && ( is_post_type_archive( 'products' ) || is_tax( array( 'products_category', 'products_tag' ) ) ) ) {
                $query->set( 'posts_per_page', '25' );
		$query->set( 'orderby', 'menu_order' );
		$query->set( 'order', 'ASC' );
	}
}
add_action( 'pre_get_posts', 'be_products_query' );

by Jack Alltrade on August 5, 2019

Filed Under: Code Snippets Tagged With: Page Attributes, WooCommerce

Reader Interactions

Share Your Two Cents Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Categories

  • Code Snippets
  • Development
  • File Management
  • Genesis Framework
  • Hosting
  • Legacy
  • Plugins
  • SEO
  • Tech Terms
  • Themes
  • User Experience
  • User Interface
  • WordPress Core
  • WordPress Functionality

Warning! Use at your own risk!

As always, use at your own risk and remember to backup your site prior to inserting new code.

© Copyright Jack Alltrade & Associates 2025 · Purely Supplemental™ is a trademark of Jack Alltrade & Associates