I have a Wordpress site with multiple authors.

When i see a user profile page i want to have a list (maybe links) of the posts this user is the author of.

How can i do it?

I thought maybe running a standard Wordpress loop with author query but i don't know how to inject that php code in the user admin panel and i don't know if it will work and if that's the right approach...

  • Have a look at this. – lowtechsun Jun 22 '17 at 8:27
  • That's nice, thanks, but i'm looking for a solution that will list them inside the user profile page and not in the users list columns. – Nori Jun 22 '17 at 8:42

You can use edit_user_profile (when viewing other user profiles) and show_user_profile (when viewing your own profile) actions to add information on profile page.

So to have there the list of posts of the selected user you could add to your functions.php:

function show_user_posts_on_profile( $user ) {

    $args = array(
        'author' => $user->ID
    $user_posts = get_posts( $args );
        <h2>User Posts</h2>
            <?php foreach($user_posts as $user_post): ?>
                <li><a href="<?php echo get_permalink($user_post->ID); ?>"><?php echo $user_post->post_title; ?></a></li>
            <?php endforeach; ?>
add_action( 'show_user_profile', 'show_user_posts_on_profile' );
add_action( 'edit_user_profile', 'show_user_posts_on_profile' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.