(using 2.6.1) – I have a site that is basically like a member directory. I am using the author.php template file to create a “profile page” about each member.
However, WordPress doesn’t “create” a user’s author page unless they have at least 1 post. Is there any way to change this? – so that if you visit http://www.blogname.com/author/username – it doesn’t return a 404 error and returns the author.php template for that user?
Hmm.. You could by default add a blank post for each user that simply says that they haven’t posted anything yet and put it in a special category.
The author.php could look for all posts by the author and if the count is one, simply show that single post.
If it is greater than one, you can simply requery and remove the special “no posts” category from the query with query_posts(‘category_name=-NoPosts’) or something like that.
If you really wanted to get fancy, you could make a plugin to change the user registration page to automatically add the blank post on sign up, thereby automating the entire thing.
Your only “manual” intervention at that point would be on wordpress updates that somehow mess up how your new plugin worked.
Not exactly straight forward, but it could work. 🙂
Best of luck,
thanks, those suggestions make sense, but does anybody know if there is an underlying reason why WordPress does not create an author page if the person doesn’t make a post – and then how maybe to change this?
If any auto-produced posts query produces zero posts, then it gets tossed over to the 404 handler. This happens for any query of any kind, not just authors.
I think another way of putting it is that WordPress never really creates ANY pages until there is a request. In fact, even after that request, the page itself isn’t really created with any permanence – it is just streamed to the requesting user.
Given that architecture, as Otto said, you’d have to muck with the code for the 404 handler, or possibly with the query code to redirect how a zero post author query is handled if you wanted to change it. I’m not familiar with that part of the code, but in theory, you could perform the query, and if it is an author query and the post count is zero, you could inject a post into the array that is a single “new author” post. So, one post would be displayed for all authors who haven’t posted anything.
This “injection” could be done by either directly pushing a post ID into the array (if you can do that without messing up WP) or by performing a second query that will simply always return the single “no author” post.
I think you should be able to do that with a plugin structure?? If not, upgrades would be a nightmare.
Anyway, hope these thoughts are even remotely useful. 🙂
Best of luck,
thanks – both of your responses are very helpful. i understand what is going on now.
as for what to do to solve it – i am not sure how to. i wouldn’t even know where to start. i agree it would have to be a plugin. i’ll muck around and see what i can find – but if anyone has any thoughts let me know.
You might try this plugin: http://wordpress.org/extend/plugins/profiler/
I haven’t personally used, it but it looks like it does what you want.
I created a plugin which prevents the 404 at the authors page, when the author has no posts:
- The topic ‘users “author” page without posting?’ is closed to new replies.