netmix / radio-station

Radio Station WordPress Plugin (Open Source)
https://netmix.com
GNU General Public License v3.0
19 stars 14 forks source link

[Author Archive] Author Template Option #36

Open tonyzeoli opened 5 years ago

tonyzeoli commented 5 years ago

Describe the bug When Author is clickable with a link, author page is 404 not found.

To Reproduce Steps to reproduce the behavior:

  1. Go to widget sidebar or Show page
  2. Click on Author link
  3. Returns 404 page not found

Expected behavior Returns Author page

Screenshots Did not take screenshot.

I'm going to assume we need to give instructions that the author.php needs to be included in a child theme or something like that. Is that correct?

majick777 commented 5 years ago

Hmm this is kinda a tricky one... Firstly, the 404 should not be appearing on standard author template pages (assuming the user exists, which it does if a link is generated for it.) If that is happening, there is a theme issue. In any standard theme an author display would be handled by author.php, or otherwise fallback to archive.php for the author archive display. Without debugging, I don't know yet why this is not happening on the demo site's theme (Make.) As /author/ is a standard rewrite path for author archives, a quick look at the theme shows me that that it should be handled by the archive.php template... It could be a permalink issue? (Try resaving the permalinks at Settings -> Permalinks to flush the rewrite rules.) As this is not actually a plugin bug, but rather something with the theme, I'm removing the bug label from this issue. (Can look into it separately if it's still happening on demo site after resaving permalinks.)

Beyond this, we need to consider under what conditions the "DJ" author template could automatically load (apart from the already available option to the user to copy author.php to their child theme directory.) Because a user might for example have both an administrator and DJ role assigned... So automatically overriding the existing author archive template with the DJ one in all cases would override say, the standard post author's theme template also (which may be an existing custom one or theme default that has matching theme markup.) This is basically why it hasn't been done before.

Of course it can be done - if we are careful with the conditions. But this would probably involve creating a new rewrite rule so that the path /dj/ shows the plugin's DJ "author" template whereas the standard /author/ is left alone. This would make a lot more sense, but is also probably something that would need to be made into a plugin option. Gven the existing option to copy the author.php template, you probably wouldn't want to do both. So as there are some complex conditions here requiring some thoughtful coding (and an admin screen) I this is best left for a future enhancement.

For now, what I did include it the last update when adding the option to link DJ names in the widgets will account for this somewhat (my thought was maybe someone wants it to make it link to the DJ's "website" user meta field rather than their author archive) - is a filter for the DJ link URL: radio_station_dj_link ...I did miss adding this filter to the single Show template though (since this is the other place where DJ names are linked from) - so I've added that to there now for the next release.

Filter example (to change link URL to DJ's website user meta value)

add_filter('radio_station_dj_link', 'custom_dj_website_link', 10, 2);
function custom_dj_website_link($url, $user_id) {
    $dj = get_user_by('id', $user_id);
    if (!empty($dj->user_url)) {$url = $dj->user_url;}
    return $url;
}

Well that was a mouthful.

tonyzeoli commented 5 years ago

This all makes sense. You're right - it would impact the author page for the true "author" role. And, yes, you can add author.php to the child theme for Make, but you're right, it would still impact things given that the DJ is a member role.

When I saw that the DJ is actually a member role, but didn't have a resulting DJ page, that certainly was problematic in my mind, because we shouldn't return a 404 and many people using this plugin might not be using a child theme or even know how to do that with their current theme.. I think adding a text field for a link to an external page (Twitter, Facebook, etc is sufficient. They could even reference a link to a Page called "DJ Tony" if they so chose. That page just won't have their Show schedule they're assigned to.

I did change the theme just now to WordPress Twenty Twelve, so that we have it as a base to work from and not the Make theme. When I switched, I still didn't link off to the Author page, so it's the member role, I think of DJ, that is throwing that off. If you're a DJ, then you're not an Author. I would think if you were an Author, then it would be switched.

I guess I understand why Nikki added the DJ role, so that a DJ could create a playlist and tie that playlist to their show. But that leaves the DJ without his/her own page. I guess in her mind the DJ wouldn't publish posts either. Just playlists. So keeping DJ separate from Author makes sense if that's the case.

So, yes, linking offsite or to a Page is the correct path here. I would just like to maybe see a DJ widget added so that they can add the Show and Show Times they are a DJ of. That way, if they create a Page for themselves that is their DJ name, they can at least have a widget that defines what show they are attached to and the times of that that show on that page.

majick777 commented 5 years ago

So as this was persisting I had another look, and my initial assumption was not quite right. Author pages do 404 in WordPress if the author has written no blog posts. For DJs, this is why the 404, they may have Shows assigned but not written a post. A bit of a frustrating situation here. I have put some code in the latest 2.2.8 release so that at least it won't 404, but will still currently say whatever message is in the theme to the equivalent of "this author has no posts" or "nothing found".

Thing is we can't really rely on the Author Template to in a theme to show anything other than a list of posts from the WP Query... I was trying to alter this so that is would display the DJ's assigned Shows also. Further, because DJ assignments are in the Show post meta, it makes it tricky to find and display those shows. I made an initial attempt to use the WP Meta Query class to combine the display but it is really complex query which it doesn't want to handel, so no luck with that one so far. It would give a mixed list anyway and maybe it would be better and easier to just add the DJ's Shows above the blog posts? (they will appear in the same way that the theme displays blog posts.)

Otherwise we are back to the previous plan of having a separate "Show" archive for the DJ view, which doesn't quite make sense now that I have looked into it. What we really want is a separate "page" - not archive - for each DJ so that it is more like a profile. It needs to be a page rather than an archive page so we can then use a content filter to produce a similar kind of result as the Show page... perhaps with a similar display format and a list of the DJ's Shows, Blog Posts (and Playlists?) in tabs. So this is what I'll be going for, it may just be a URL rewrite for /dj/%author_name%/ to a single page template but I'll see when I get to it.

tonyzeoli commented 5 years ago

Okay, here's what I'm thinking then.

  1. Admin creates User and assigns the role of DJ
  2. Admin creates a Show and assigns the DJ to the Show with the Hosts meta box (as they do now)
  3. If Admin creates a page for the DJ with a new CPT of Host(s)/DJ(s) and assigns the DJs using the Host meta box as they do now, then if DJ has a show page, set the link to target the DJs CPT page, but if DJ has no page, then print the name on the screen but disable the link, as we don't want the visitor going to the author.php page.

This way, if a DJ is listed as a Show host but can't click on their name, then they'll tell the admin/webmaster at the station and a DJ page will be created for them.

I think that works.

I don't think we need to add Posts or Playlists yet to the DJs CPT - we'd just have "Back to Show" (they came from along thee breadcrumb trail) because there are too many variables with the DJ wheras they might want to display shows they were there for but not display shows they missed and that sort of thing. The Show can house all that stuff as it does now, but the DJ page only needs a photo, bio, email link, website link, and related shows links if they are on more than one show.

majick777 commented 4 years ago

Related to #88

kairandles commented 3 years ago

Not having this direct issue with 404 however I've created a redirect for anything in my domain.com/writer/.* To redirect to the schedule (did this with a simple redirection plugin but can be done in the .htaccess or domain side of your site)? Might help you out?