AI Verified

Name

Add Alphabetical Sorting to Woocommerce

About

Sorts products alphabetically in Woocommerce

Language

PHP

Rating

Voted: 2 by 2 user(s)

How to Setup Snippet

This is for woocommerce themes that do not provide alphabetical sorting. Just add snippet to code snippets. Your products should be sorted and you should see an "Alphabetical" in the Woocommerce sort options dropdown.

Codevault

George Snippet Library

Scroll down to see more snippets from this codevault.

Wordpress Compatability

The author has indicated that this snippet is compatable up to wordpress version: Not Specified

Our AI bot has checked this snippet is compatable up to wordpress version: 6.1

Code Snippet Plugin Sync

Free & Pro

Download this snippet by clicking the download button, then head over to the Code Snippet Plugin settings in your wordpress admin dashboard, select the import menu then upload this file to import into your wordpress site.

Pro Only (Coming Soon)

You will be able to click a button and sync this snippet to your wordpress site automatically and from your dashboard manage all code snippets across all your wordpress sites that have the Code Snippets Pro plugin installed.

History

Last modified:

06/07/2024

Important Note

This snippet has the following status:

AI Verified

This snippet has been tested by our AI bot, see any comments below.

AI Bot Comments:

Found 0 vulnerabilities

Add Alphabetical Sorting to Woocommerce

 
                    
1function gncy_custom_woocommerce_get_catalog_ordering_args( $args ) {
2 $orderby_value = isset( $_GET['orderby'] ) ? woocommerce_clean( $_GET['orderby'] ) : apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) );
3 
4 if ( 'alphabetical' == $orderby_value || 'menu_order' == $orderby_value ) {
5 $args['orderby'] = 'title';
6 $args['order'] = 'ASC';
7 }
8 
9 return $args;
10}
11 
12function gncy_custom_woocommerce_catalog_orderby( $sortby ) {
13 $sortby['alphabetical'] = __( 'Alphabetical' );
14 return $sortby;
15}
16add_filter( 'woocommerce_default_catalog_orderby_options', 'gncy_custom_woocommerce_catalog_orderby' );
17add_filter( 'woocommerce_catalog_orderby', 'gncy_custom_woocommerce_catalog_orderby' );
18add_filter( 'woocommerce_get_catalog_ordering_args', 'gncy_custom_woocommerce_get_catalog_ordering_args' );

2

Comments

Related Snippets

Please see some snippets below related to this snippet..

WooCommerce

AI Verified

0

Shipping by Weight

Added: 1 year ago

Last Updated: 1 year ago

WooCommerce

AI Verified

1

WooCommerce Custom Text After Register Form Fields

Added: 1 year ago

Last Updated: 2 weeks ago

This guide shows you how you can add any custom text below the form fields on the Register form on the My Account page.

WooCommerce

AI Verified

0

Remove "Has Been Added to Your Cart" WooCommerce Message

Added: 1 year ago

Last Updated: 1 year ago

Other Snippets in this Codevault

These are some popular snippets from this users codevault..

WooCommerce

AI Verified

5

Delete Woocommerce images after deleting product

Added: 1 year ago

Last Updated: 1 month ago

Automatically Delete WooCommerce Images After Deleting a Product. If you use the same image of multiple products the image will not be deleted for those

WooCommerce

AI Verified

2

Add Alphabetical Sorting to Woocommerce

Added: 1 year ago

Last Updated: 2 weeks ago

Sorts products alphabetically in Woocommerce

WooCommerce

AI Verified

1

Remove categories from the shop and other pages in Woocommerce

Added: 1 year ago

Last Updated: 1 year ago

Remove any categories from WooCommerce frontend