2

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?

7
  • Possible duplicate of Get only modified posts Commented Jul 5, 2018 at 13:40
  • I need get post not modified, not only modified, next time read the question please... no duplicate... Commented Jul 5, 2018 at 15:25
  • 1
    Which has the same answer with an extremely simple change from the solution to the other question. Just change != (not equals) to =. Commented Jul 5, 2018 at 15:31
  • The query is different... AND {$wpdb->posts}.post_modified} != {$wpdb->posts}.post_modified}, post_modified != post_modified?? really?? a =! a?? How to implement in my qp_query?? Commented Jul 5, 2018 at 15:43
  • You can't do it in WP_Query. Which is covered in the question I marked as duplicate. Commented Jul 5, 2018 at 15:44

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.