I have a custom PHP file to get all the users/authors from the DB in WP, so it's all showing correctly and working BUT, I want to make the comment to work properly, what i did now is:

  <?php comments_template(); ?>

I added the above line in the file, but the issue is that if i comment on one author the comment won't stay ONLY on his profile page, but it will publish in all the authors page, it's like the comment are not individual....

Any ideas how can i make the commenting work for each author separated from the other?

1 Answer 1


Comments are bound to post IDs. So you need a post ID for each user.

Register a custom post type, make it not public and create one hidden post for each user. Store the ID in an user-meta field.
Now assign the comments to that post’s ID. Do not use comments_template(). That’s an ugly monster, dealing with globals and way too complex to hack around. Fetch the comments with get_comments() instead.

The print the comment form, add a hidden field for author archive URL, hook into comment_post_redirect and send the commenter back correctly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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