我有一个自定义主页,只要用户登录,他们就会看到他们帐户的概述。我想向他们展示他们自己的所有帖子,但我遇到了麻烦,只能让他们向所有人展示当前发布的帖子。我需要只显示登录用户自己的帖子
我也有问题的类别显示所有类别的职位类型,而不仅仅是什么职位。我需要使用什么而不是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(); ?>
最合适的回答,由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\' ) ) );