php - List posts in WordPress with Key which is the post id -


i have function in wordpress lists ids of custom meta posts in wordpress , function current user meta function. query:

<?php     $args = array(          'post_type' => 'todo_listing',          'posts_per_page' => 4,         'order'=>'asc'          'meta_query' => array(             array(                 'key' => $id,                 'meta_value_num' => '1',             )     ));     $loop = new wp_query( $args ); ?>        <?php     while ( $loop->have_posts() ) : $loop->the_post(); ?> <?php echo get_the_id();?>   <?php     endwhile; ?>   

i want list posts key id of post , has key value 1.

the above code not work. how can make work?

try this:

$id = get_queried_object_id();  $args = array(      'post_type' => 'todo_listing',      'posts_per_page' => 4,     'order'=>'asc'      'meta_key' => $id,     'meta_value_num' => '1', ); 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -