I am trying to create a post list that will show current users posts by specific category and show the post id inside the title. So, I wrote the code below, but it isn't working work. Any suggestions please:
<?php
if ( is_user_logged_in() ):
$user_id = get_current_user_id();
$args=array(
'post_type' => 'post',
'post_category' => array( 2 ),
'posts_per_page' => 10,
'author' => $user_id
);
$wp_query = new WP_Query($args);
while ( have_posts() ) : the_post();
?>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php get_the_ID(); ?></a>
<?php
endwhile;
else :
echo "not logged in";
endif;
?>
echo get_the_ID();
instead of justget_the_ID();
.