WP_Query compare with dynamic values

I need get a post only if publish_date is equal to modified date in this case the post is not modified! So i need post NOT MODIFIED!:

My query is:

 $lastupdated_args = array(
        'paged' => $paged,
        'orderby' => 'modified',
        'ignore_sticky_posts' => '1',
        'post_status' => 'publish',
        'post_type' => 'post',
        'date_query' => [
        [ 'before' => 'post_modified' ]
    ],
        'date_query' => [
        [ 
            'column'    => 'post_modified_gmt', 
            'after'     => 'post_date_gmt', 
            'inclusive' => false 
        ]
    ],

    ); 

    function wpse_modified( $where ) {
        global $wpdb;
        // Run only once:
        remove_filter( current_filter(), __FUNCTION__ );
        // Append custom SQL
        return $where . " AND {$wpdb->posts}.post_modified} != {$wpdb->posts}.post_modified} ";
    }

    add_filter( 'posts_where', 'wpse_modified' );

    $lastupdated_loop = new WP_Query( $lastupdated_args );
    query_posts( $lastupdated_args );

How to get a dynamic value like date (published and modified) during this query for comparison?

0

Leave a Comment