Categories

Monday, May 20, 2024
#919814419350 therichposts@gmail.com
WoocommerceWordpress Hooks

WordPress Hook – Show Woocommerce Products Alphabetical Order

How to add custom meta title and meta description in Wordpress?

Wordpress Hook – Show Woocommerce Products Alphabetical Order

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

 

therichpost
the authortherichpost
Hello to all. Welcome to therichpost.com. Myself Ajay Malhotra and I am freelance full stack developer. I love coding. I know WordPress, Core php, Angularjs, Angular 14, Angular 15, Angular 16, Angular 17, Bootstrap 5, Nodejs, Laravel, Codeigniter, Shopify, Squarespace, jQuery, Google Map Api, Vuejs, Reactjs, Big commerce etc.

Leave a Reply

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