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
Post a Comment