Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Logged in User - Your Recent Post & Your Recent Comments WordPress


I am building a wiki site that requires all users to be logged in, in order to see the content.

In the footer I would like 4 widgets:

- Recent Posts (This is working fine)
- Recent Comments (This is working fine)
- Your Recent Posts
- Your Recent Comments

I would like 'Your Recent Posts' to show the last 5 posts that the logged in user has created.
I would like 'Your Recent Comments' to show the last 5 comments that the logged in user has made.

I'm not sure if there is a plugin out there that can do this or someone can help edit the current widgets to do this?

Answers (4)


Agus Setiawan answers:

logged user recent post :

if ( is_user_logged_in() ) {
$user_id = get_current_user_id();
query_posts( "author=$user_id&posts_per_page=5" );?>

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>">
<?php the_title(); ?></a>

<?php endwhile; else: ?>
<p><?php _e('You Have No Submissions'); ?></p>

<?php endif; ?>
} else {
('You Have No Submissions.');

Agus Setiawan comments:

for recent comments by logger user, use this plugin :

hope this can help you


Jurre Hanema answers:

Please install and activate the attached plugin I created. It will add the widgets you are looking for.

They work exactly the same as the "Recent Posts" and "Recent Comments" widgets included with Wordpress, except they only show the posts or comments from the currently logged in user. If no user is logged in, the widgets don't show anything.

Ross Gosling comments:

Thank you for creating the plugins. I actually used your widget for 'Your Recent Articles' but I used Agus's recommendation for the 'Your Recent Comments' solution as that worked straight out the box.

Thank you


Francisco Javier Carazo Gil answers:


Try this plugin:

Francisco Javier Carazo Gil comments:

Sorry, I hadn't seen your attachment.

Send me code of the plugin/function that generate your widget and I can custom it to make it only post own posts or own comments in the two cases you need.


Arnav Joy answers:

I can help you by creating new widgets