我想创建一个页面,只显示登录用户写的帖子,并获得一个链接(如www.example.com/AuthorPostsID)以放在菜单上。我试了两天。有人知道怎么修吗?谢谢
编辑:我尝试使用以下代码,将其放入函数中。php文件,但我不知道如何继续:
if ( is_user_logged_in() ):
global $current_user;
get_currentuserinfo();
$author_query = array(\'posts_per_page\' => \'-1\',\'author\' => $current_user->ID);
$author_posts = new WP_Query($author_query);
while($author_posts->have_posts()) : $author_posts->the_post();
?>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a>
<?php
endwhile;
else :
echo "not logged in";
endif;