WoocommerceWordpress Hooks

WordPress Hook – Show Woocommerce Products Alphabetical Order

Wordpress Hook – Show Woocommerce Products Alphabetical Order

wordpress cheat code to update User Password mysql query
362Views

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

 

Ajay Malhotra
the authorAjay Malhotra
Hello to all. Welcome to therichpost.com. Myself Ajay Malhotra and I am full stack developer. I love coding. I know Wordpress, Core php, Angularjs, Angular 2, Angular 6, Angular 7, laravel, Codeigniter, Shopify, Squarespace, Jquery, Google Map Api, Vuejs, Reactjs, Bigcommerce etc.

Leave a Reply

Positive SSL