1

I've got a page displaying all WP users using get_users() and get_userdata(). I need an individual user page automatically (with its own slug) generated for each new user added.

I'm a bit clueless about how to achieve that. Any suggestions?

2

I guess what you're looking for is an author template. You can create an author.php in your template folder and arrange the information in there like you want to. It will be a general template for every user then. You can access the author page if you visit example.com/author/author-slug/

To give an example: http://bookish.brokenstars.de/author/fyn/

I'm sorry it's a german site. However, you see that on this author page all posts from this author are displayed. But like I said, you can put whatever information you want into the template, like the description ect. I guess it's the easiest way.

Reference: https://codex.wordpress.org/Author_Templates

|improve this answer|||||
  • Won't author archive 404 without posts? – Rarst Apr 17 '14 at 12:37
  • No, it will work nevertheless! If you take a look at the reference I posted and scroll down to the end, there's a good example how such a template could look like ("Sample Template File"). If you don't want the posts to show up you can simply remove the loop from the template. – Fyn Apr 17 '14 at 12:48
  • Huh, that's not what I would expect. Getting some notices thrown inside a WP_Query though, so I am on the fence if it is a good idea for post-less users. – Rarst Apr 17 '14 at 12:55
  • Hmh, you could also keep the loop and display the "No posts by this author." message if there are none. But I think it's okay to remove it, because after all they get the author from the url slug (if you consider the reference example) so a query isn't required. Maybe it fails if you're using one of the other example snippets to get the current user. – Fyn Apr 17 '14 at 13:03
  • I created a new user, posted a post with that user, created a "author.php" template, yet on the page running the wp_list_authors() function when I click on this author, I see the right slug but I get the very same page, not the author page. – drake035 Apr 17 '14 at 13:54

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.