[Resolved] Sort By Custom Field Value

Please login to receive premium support.

Support for the free plugin can be found here.

Home Forums Pro Support Sort By Custom Field Value

Viewing 16 post (of 16 total)
  • Author
    Posts
  • #35567
    elvin
    Moderator

    Let’s modify the code a bit.

    Try this:

    add_filter( 'wp_show_posts_shortcode_args', function( $args, $settings ) {
        if ( 7 === (int) $settings['list_id'] ) {
    		$args['meta_key'] = 'time';
    		$args['orderby'] = 'meta_value';
    		$args['order'] = 'ASC';
        }
    	
        return $args;
    },10,2 );

    This should work as tested on a sandbox site.

Viewing 16 post (of 16 total)
  • You must be logged in to reply to this topic.