No results found. Try again with different words?

Search must be at least 3 characters.

    How to filter Query Parameters in Advanced Posts?

    Advanced posts are loved by a lot of people due to its flexibility to modify query parameters. But, in some cases, developers need to modify the query parameters which are not specified in options. Let’s say you are displaying events using Advanced posts module and you want to disregard past events. Let’s assume that the event date is specified in meta with key `event_date`. Also we are checking with HTML id `events-list` before modifying the parameters so that this won’t be applied to all blog post modules on the site.

     /* Advanced Query Parameters filtering for UABB Posts module */ 
    function your_prefix_uabb_blog_posts_query_args( $args, $settings ) {
    // Give an HTML id and check it before modifying arguments so that it will not be applied to all blog post modules on the site.
    if ( $settings->id == 'events-list' ) {
    $args['orderby'] = '';
    $args['meta_key'] = 'event_date';
    $args['nopaging'] = true;
    $args['posts_per_page'] = '2';
    $args['meta_query'] =
    array(
    'key' => 'event_date',
    'compare' => '<', 'value' => date( "Ymd" ),
    'type' => 'DATE'
    );
    }
    return $args;
    }
    add_filter( 'uabb_blog_posts_query_args', 'your_prefix_uabb_blog_posts_query_args', 20, 2 );

    We are using `uabb_blog_posts_query_args` filter to accomplish this. You can take a look at all our filter reference.
    You need to put the above code snippet in functions.php file of your theme/child theme.

    This is just one example. You have lots of possibilities to filter posts with WP Query Parameters.

    Was this article helpful?

    Did not find a solution? We are here to help you succeed.

    Related Docs

    Grab this rare opportunity to save up to 50%

    WOAH, HOLD ON THERE!

    Don't Miss Our Biggest Discount

    00
    Months
    00
    Days
    00
    Hours
    00
    Minutes
    00
    Seconds

    You are backed by 100% risk-free money-back guarantee.

    Grab Our Biggest Discount Of All Time. Don’t Miss Out!

    00
    Months
    00
    Days
    00
    Hours
    00
    Minutes
    00
    Seconds

    Free Download

    Enter your name & email address to download this awesome freebie.

    Free Download

    Enter your name & email address to download this awesome freebie.

    Free Download

    Enter your name & email address to download this awesome freebie.

    Free Download

    Enter your name & email address to download this awesome freebie.

    Free Download

    Enter your name & email address to download this awesome freebie.

    Free Download

    Enter your name & email address to download this awesome freebie.

    Free Download

    Enter your name & email address to download this awesome freebie.

    Free Download

    Enter your name & email address to download this awesome freebie.

    Free Download

    Enter your name & email address to download this awesome freebie.

    Free Download

    Enter your name & email address to download this awesome freebie.

    Free Download

    Enter your name & email address to download this awesome freebie.

    Free Download

    Enter your name & email address to download this awesome freebie.

    Scroll to Top