Author Page with no posts
-
I’ve been searching around for a solution to this one but am having no joy.
I’m developing a website for a record label. Each artist on the record label will be an author on the site and is allowed to post articles etc. This is convenient as it allows each artist to edit their profile and this is what will appear on their “Artist Page” on the site.
So, an example of a page that this works on is:
https://devel.invisibleagent.com/author/ebauche/
I have attributed one test post to this author and his profile appears and correctly uses the author.php template file in my theme.
However for all artists that don’t have any posts attributed to them, I just get a 404 page. It was suggested here that having an author.php template file sorts the issue, but it clearly doesn’t.
So if you go to another author page on the site you get the 404.php template.
I would like to avoid having to actually create a “My first post” for each artist on the site, as I don’t think this will look very professional.
I had toyed with incorporating the artist bio’s into another page on the site, https://devel.invisibleagent.com/artists/ but this makes for a very long page, and after a lot of playing with accordion affects we’ve decided that what we really want is essentially a list of authors and their photos which links through to their profile.
Is there any way to force WordPress to display the /author/ page when they don’t have any posts?
If not, then I will have to look at some fun and games with PHP and possibly a link structure like /artists/?artist=ebauche
I think something like this would allow me to code my artists-page.php template to grab that variable and then only display the artist listed, their picture, their bio, and only show posts if they have any. However I’ll have to test this out some..
Maybe something like the below (my plain english type code again ??
$artist = NULL; $artist = $_GET['artist']; if (! empty ($artist) ) { // get artist info from database (might need to use ID instead of nickname to enable this if artist id exists { display bio, photo, if posts show them; } else { display error message and fall through to display all artists; } } else { if the url doesn't have the additional ?artist= then display basic page with all artist photos and links to ?artist=ID }
That would probably do it – I’m sure it’s workable, but obviously it would be great if I could just use the author.php template in all cases, posts or not!
By the way, thanks to Kaf Oseo (https://szub.net/) for his excellent “All Authors Template” which I’m using on this artists page. Very nice stuff.. ??
- The topic ‘Author Page with no posts’ is closed to new replies.