Welcome to therichpost.com. In this post, I will tell you, WordPress Hook – Show Woocommerce Products Alphabetical Order. Like I always say WordPress is the best cms.
Many of my blog users say that, I write very less and this is true, I should increase my writing skills but my main motive is give code snippet and solve the issues.
I love to write codes and post on my blog.
Here is the working and tested hook for Wordpress Hook – Show Woocommerce Products Alphabetical Order and you need to add this hook into your theme’s functions.php file:
add_filter( 'pre_get_posts', 'custom_wpquery' );
function custom_wpquery( $query ){
if (is_post_type_archive( 'product' )) {
$query->set('post_type', 'product');
$query->set('orderby', 'title');
$query->set('order', 'ASC' );
}
};
If have any query related to this post, then do comment below or ask questions.
Thank you,
Happy Coding,
Thericpost
