Disable author pages for users with no posts?

Posted in: Newsmag
Post count: 26

Hi there,
I’m wondering whether this is a theme feature. By default author pages seem to be created even if the user has no posts, which is leading to author pages being created for subscribers. I was wondering whether there is a way to disable this?

Thanks!

Post count: 9544

I think this is function of WordPress … WordPress creates automatic pages for things like categories, tags, authors/users, etc. — the theme only changes the look of those things, it doesn’t create new pages, posts or tags for you, or users.

Whenever you create a new user, there is an index for that user under their username, and even under the user-id. It is basically the same as an archive, except has a custom template. Typically there would NOT be an index for a “subscriber,” AFAIK. But editors, and contributors, all get author indexes by default.

You can hide “empty” author indexes from your sitemap using Yoast SEO; which I do. 🙂

In things like author widgets (“featured authors”) you can hide un-used and admin authors by their author ID code.

  • This reply was modified 11 years by simchris.
Post count: 26

Hi Chris,
Thanks for the quick reply! Excellent support. So subscribers will have author pages created for them on signing up? I’ve been looking for a fix to direct subscriber author pages to 404, or preferably not create them at all. Really sorry if this isn’t theme related, I’ll direct that one to WordPress.

Also I was wondering whether the top bar sign in could be linked. I’ve created a page for editing user profiles without the dashboard on the front end. I was hoping to add this link to the td_user_logd_in call href call.

Post count: 9544

Make sure you have your default “user role” in WP set to “subscriber.” A new user should not be able to have an “author” index, since a subscriber cannot make posts, only “view” posts. See the official WordPress CODEX on “user roles” for more information on that 🙂

Post count: 26

That’s what I’ve been so confused about, it’s subscribers that are getting author pages. I thought it might be the theme but now I’m wondering whether it could be a plugin issue. Example at http://www.xposy.com/author/testsubscriber – Account I made with default user role set to subscriber. Very strange!

Post count: 26

Does anyone happen to know if the plugin Profile Builder happens to make any changes to the handling of this? I’m pretty stuck at the moment.

Post count: 26

Well, I’ve fixed this for now by throwing a 404 on the author.php if !have_posts, but this meant changing the author.php template. I don’t know if this is going to fix much. These pages may still be included within the sitemap. Hopefully I haven’t messed with any functionality of the author template. For anyone dealing with the same issue, in your parent theme > author.php add:
<?php
if (!have_posts()) {
header(“HTTP/1.0 404 Not Found – Archive Empty”);
require TEMPLATEPATH.’/404.php’;
exit;
}
get_header();
?>
To the very top of the file. Unfortunately these are still being indexed, so I’m expecting a few errors in Webmaster Tools.

  • This reply was modified 11 years by Sean.
Post count: 26

I realised this doesn’t overwrite existing header information created by certain plugins such as Yoast SEO. Instead, place this at the top of the author.php file:

<?php
if (!have_posts()) {
global $wp_query;
$wp_query->set_404();
require_once( trailingslashit( get_template_directory() ). ‘404.php’ );
exit;
}
?>

Post count: 26

Final edit, my apologies. I used the wrong require 🙂

<?php
if (!have_posts()) {
global $wp_query;
$wp_query->set_404();
require( trailingslashit( get_template_directory() ). ‘404.php’ );
exit;
}
?>

Post count: 9544

Also, in your YOAST SEO setup for XML sitemaps — they *did* add option this year to NOT include authors by user role, so you can check the

EXCLUSE
[X] admin
[X] subscribers

this will keep out admin and subscriber posts from sitemap; and only those with actual editor, contributor (writers) roles in the sitemap(s).

Post count: 26

Thanks Chris, I’ll check my settings for that. Hopefully that will sort out the last of my troubles

Post count: 26

Sorted the top bar log-in section with a quick change to top-menu.php:

<li class=”menu-item”>’ .
get_avatar($current_user->ID, 20) . ‘<Your Anchor>’ . $current_user->display_name . ‘<End Anchor><i class=”td-icon-logout”></i>’ .

And the following CSS:

.td_user_logd_in{
cursor:pointer!important;
}

Looks like I’m all sorted!

  • This reply was modified 11 years by Sean.
  • This reply was modified 11 years by Sean.
Post count: 9544

🙂

and of course I meant “exclude” not “excluse” …
sheesh.

Don’t try typing in this forum on your iPad (!).

Post count: 26

Haha, I found the area you were talking about, all nice and hidden now. Cheers Chris! 🙂

Viewing 14 posts - 1 through 14 (of 14 total)
The forum ‘Newsmag’ is closed to new topics and replies.