Description
Allows to add or delete the types of sorts. The default sorting types are:
- order, called ‘Recommended’,
- price
- title
- author
- date
- comment_count, called Popular
Parameters
- $sorting_fields
- (Array) Array of types of sorts. A type of sort is another array with two field, value and title.
Example
<?php
function my_sorting_fields( $sorting_fields ) {
//adds a new sorting method
$sorting_fields[] = array(
'value' => 'stock',
'title' => __( 'By Stock', 'textdomain' )
);
//removes one of the default sorting type, in this case the author sorting method
unset( $sorting_fields['author'] );
return $sorting_fields;
}
add_filter( 'tcp_sorting_fields', 'my_sorting_fields' ); ?>
To see a more detailed example, visit the page how to add sorting methods.
Change Log
Since 1.1
