Search
 
SCRIPT & CODE EXAMPLE
 

PHP

Sorting Products by Custom Meta Fields

add_filter( 'woocommerce_shortcode_products_query', 'woocommerce_shortcode_products_orderby' );

function woocommerce_shortcode_products_orderby( $args ) {

    $standard_array = array('menu_order','title','date','rand','id');

    if( isset( $args['orderby'] ) && !in_array( $args['orderby'], $standard_array ) ) {
        $args['meta_key'] = $args['orderby'];
        $args['orderby']  = 'meta_value_num'; 
    }

    return $args;
}
Comment

PREVIOUS NEXT
Code Example
Php :: Laravel API ResourceCollection doesnt works 
Php :: bootstrap autocomplete example ajax php mysql 
Php :: laravel orm latest() 
Php :: <= in php 
Php :: bu7scador con laravel 
Php :: waht is middleware in laravel 
Php :: php printf percent sign 
Php :: javascript,php error 
Php :: wordpress programmatically set acf taxonomy term 
Php :: undefined type excel 
Php :: php array dot notation 
Php :: laravel many to many relationship with pivot table 
Php :: with() multiple relationship 
Php :: php clear echo messages 
Php :: php obtener slug wordpress 
Php :: Convert English Date Time To Persian Date Time JDF PHP 
Php :: Argument 1 passed to DoctrineInflectorInflector::singularize() must be of the type string, null given, 
Php :: php if condition 
Php :: Number in English Words (Indian format) php 
Php :: order review checkout page reset woocomerce 
Php :: wordpress add sitemap.xml to robots.txt dynamically 
Php :: php 7.1 functions parameters with "?" 
Php :: laravel eloquent get current sequence value 
Php :: mysql.service: Start request repeated too quickly 
Php :: get next day date in php 
Php :: call node js jquery http php 
Php :: php remove new line character from string 
Php :: laravel download file from AWS s3 
Php :: beanstalk run laravel command 
Php :: wc php retrieve the order Id on Order pay page 
ADD CONTENT
Topic
Content
Source link
Name
9+8 =