Thursday, August 11, 2022
HomeWordPress Developmentwp question - wp_query loop with evaluate operator merely not working, why?

wp question – wp_query loop with evaluate operator merely not working, why?


Annoyed and would love some assist with this.

I’ve a customized put up subject titled ‘expire_date’. When the expire date is reached, I need that put up to to drop off of the checklist of posts which might be returned.

I exploit Generate Blocks, and help at Generate Press have been variety sufficient to provide me some code that they are saying ought to work for what I need.

Nonetheless, it does not. Not one of the posts I need filtered out are filtered out.

I’ve examined the ‘if’ assertion and that query_args do work through the use of a special query_arg. It labored fantastic (and is included within the script under).

However the precise script that I must work does not. I’ve examined each manner that I can consider, double checked the customized subject and it is working and titled appropriately. I’ve modified the comparability operator to = and even tried != and it does not make any distinction. Nothing is filtered out. Why?

Thanks for any assist!

Chris

add_filter( 'generateblocks_query_loop_args', operate( $query_args, $attributes ) {
    if (
        ! is_admin()
        && ! empty( $attributes['className'] )
        && strpos( $attributes['className'], 'my-query' ) !== false
    ) {
        // cross meta_query parameter
        $query_args[ 'meta_query' ] = array(
            'meta_key'          => 'expire_date', //instance 2022-06-20
            'meta_value'        => date("Y-m-d"),
            'kind'              => 'DATE', //have additionally tried DATETIME and TIME
            'meta_compare'      => '>=',
        );
        ////in testing, this works/// $query_args['date_query'] = array( 'after' => '2022-06-01' );
    }
    return $query_args;
}, 10, 2 );

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments