Home Woocommerce Wordpress Hook – Show Woocommerce Products Alphabetical Order

Wordpress Hook – Show Woocommerce Products Alphabetical Order

by therichpost
0 comments
How to add custom meta title and meta description in Wordpress?

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

 

You may also like

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.