我使用以下代码仅获取带有post\\u类型问题和当前登录用户的帖子。
但如果没有使用记录,所有帖子都会显示出来。
有什么建议吗?
代码:
<?php global $current_user; ?>
<?php get_currentuserinfo(); ?>
<?php echo \'Username: \' . $current_user->user_login . "\\n"; ?>
<?php
$args = array(
\'post_type\' => \'question\',
\'post_author\' => $current_user->ID)
?>
<?php $custom_posts = new WP_Query(); ?>
<?php $custom_posts->query($args); ?>
<?php while ($custom_posts->have_posts()) : $custom_posts->the_post(); ?>
<div class="block-2 border-top">
<h2><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( \'Permalink to %s\', \'twentyten\' ), the_title_attribute( \'echo=0\' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
<?php the_excerpt(); ?>
<p><?php comments_number(\'0 Replies\',\'1 Reply\',\'% Replies\'); ?>.</p>
<p><?php display_votes(get_the_ID()); ?></p>
<p><?php the_views(); ?></p>
<span class="cat-links">
<?php printf( __( \'<span class="%1$s">Posted in</span> %2$s\', \'twentyten\' ), \'entry-utility-prep entry-utility-prep-cat-links\', get_the_category_list( \', \' ) ); ?>
</span>
</div>
<?php endwhile; ?>