Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 59525

Specific Filter Not Working With Custom Orderby

$
0
0

Replies: 0

Hi again,

I’ve run into a small issue and hopefully you can point me in the right direction again.

The PRICE filter – from an ACF Field – does not work because the POSTS are ordered by the PRICE.

Below is the function on how the archive is being ordered:

function wpb_custom_query( $query ) {
    if( $query->is_main_query() && ! is_admin() && $query->is_archive() ) {
    	$query->set( 'meta_key', 'price' );
        $query->set( 'orderby', 'meta_value_num' );
        $query->set( 'order', 'ASC' );
    }
}
add_action( 'pre_get_posts', 'wpb_custom_query' );

Like I said, all the other filters work fine, but for some reason the PRICE filter is not working and I presume its because of how I am ordering the posts.

Many thanks in advance! Any help will be greatly appreciated.


Viewing all articles
Browse latest Browse all 59525

Trending Articles