0

I have a custom home page set up so soon as users log in they see an overview of their account. I want to show them all of their own posts but im having trouble and can only get it to show current published posts to everyone. I need to show only the logged in user their own post

I am also having issues with the categories showing all categories in the post type and not just what the post has. What do i need to use rather than wp_list_categories to just list cats attached to post?

<?php 
 query_posts( array( 'post_author' => $current_user->ID, 'post_status' => 'publish' , 'post_type' => array(    'user_lists' )  ) ); ?>

<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
  <?php echo '<div class="tr"><div class="td style2">';
  echo '<a href="'; the_permalink(); echo '">'; the_time('F j, Y'); ?> at
  <?php the_time('g:i a'); echo '</a>';
   echo '</div><div class="td">'; 
  echo wp_list_categories('taxonomy=list_type&type=user_lists&title_li=&style=');  
  echo '</div><div class="td">'; 
  echo wp_list_categories('taxonomy=list_state&type=user_lists&title_li=&style=');  
  echo '</div><div class="td">'; 
   the_tags('', ', ', '');
  echo '</div><div class="td">'; ?>
  <form class="delete-coupon" action="" method="post">
    <input type="hidden" name="postid" value="<?php the_ID(); ?>" />
    <input class="more-button" type="submit"  value="Delete" />
  </form>
  <?php  echo '</div></div>'; ?>
  <?php endwhile; ?>
  <?php wp_reset_query(); ?>
0

I fixed the issue myself.

What i was doing wrong was the query_posts line i had read

query_posts( array( 'post_author' => $current_user->ID,'post_status' => 'publish' , 'post_type' => array(    'user_lists' )  ) );

And the correct way should be

query_posts( array( 'author' => $current_user->ID,'post_status' => 'publish' , 'post_type' => array(    'user_lists' )  ) );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.