显示来自登录作者的自定义帖子

时间:2013-06-19 作者:Noob Theory

我有一个自定义主页,只要用户登录,他们就会看到他们帐户的概述。我想向他们展示他们自己的所有帖子,但我遇到了麻烦,只能让他们向所有人展示当前发布的帖子。我需要只显示登录用户自己的帖子

我也有问题的类别显示所有类别的职位类型,而不仅仅是什么职位。我需要使用什么而不是wp\\U list\\U类别来列出附在帖子上的猫?

<?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(); ?>

1 个回复
最合适的回答,由SO网友:Noob Theory 整理而成

我自己解决了这个问题。

我做错的是我读到的query\\u posts行

query_posts( array( \'post_author\' => $current_user->ID,\'post_status\' => \'publish\' , \'post_type\' => array(    \'user_lists\' )  ) );
正确的方法应该是

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

结束

相关推荐

按自定义字段对GET_USERS排序

我有一个名为“label”的自定义用户分类法,其中还有一个自定义字段“sort\\u order”-我试图返回具有标签分类法的用户列表,然后按sort\\u order字段对该列表进行排序。到目前为止,我。。。。。<?php $users = get_users( array( \'meta_key\' => \'sort_order\', \'fields\' => \'all_with_meta\' ) ); &