Where condition for Wp_posts in WP_QUERY

I am getting problem to fetch records with WP_QUERY in wordpress. I have a working custom Query but I need this query in the form of WP_QUERY.

Select * from wp_posts where post_type = 'awards' AND post_status = 'publish' AND ID < '$lastmsg' order by ID desc limit 4;

My Arguments for WP_QUERY

Read More
$args = array(
   'post_type' => 'awards',
   'post_status' => 'publish',
   'posts_per_page' => 4,
   'meta_query' => array(
          array( 
              'key' => 'ID',
              'value' => $POST_ID,
              'compare' => '<'
          )
    )
);

Please help me. Thank in advance.

Related posts

1 comment

  1. Here is the alternative solution for your problem. I hope it will work for you.

    <?php
    $fivesdrafts = $wpdb->get_results( 
        "
        SELECT * 
        FROM $wpdb->posts
        WHERE post_status = 'draft' 
            AND post_author = 5
        "
    );
    
    if ( $fivesdrafts )
    {
        foreach ( $fivesdrafts as $post )
        {
            setup_postdata( $post );
            ?>
            <h2>
                <a href="<?php the_permalink(); ?>" rel="bookmark" title="Permalink: <?php the_title(); ?>">
                    <?php the_title(); ?>
                </a>
            </h2>
            <?php
        }   
    }
    else
    {
        ?>
        <h2>Not Found</h2>
        <?php
    }
    ?>
    

    This code have the same functionality as we use have posts query.

Comments are closed.