First I used wp_list_authors in the sidebar to make a list of all the authors that would function as a way of listing all posts by different aouthors, as it used the archives template.
Then I added an authors template in order to make profile pages for each author. For this I also had to use wp_list_authors.
Now both lists of course make use of the authors template I created because of the hierarchy.
However, what I want is two lists. One that lists the authors and generate links to all their posts using the archives template. And a second that also lists all the authors and generate links to their profilepages using the authors template.
Is it possible? Am I missing out on some important template tags that I could use? Is there a way to override the template hierarchy?
“However, what I want is two lists. One that lists the authors and generate links to all their posts using the archives template. And a second that also lists all the authors and generate links to their profilepages using the authors template.“
You’ll have to flesh out a description of this in more detail, because I’m not fully understanding it. What’s the real variation here?
OK, I’ll try to give a more detailed description:
In my main menu that is organized as a horizontal navbar I use this code in my header template:
<li><a href="<?php echo get_settings('home'); ?>/">Hjem</a></li>
<!-- mainmenu level 2 begins -->
<?php wp_list_authors('exclude_admin=0'); ?></ul>
<!-- mainmenu level 2 ends -->
This works well and the level2 list brings up all the four authors names linking to their profile pages that makes use of the author template. Here is a link to this spesific part of the site I’m working on (in Norwegian, though): http://www.saftogvann.com/sosionautene/?page_id=5
This part is fine.
But in the other sections of my site I want a list of all the authors that links to an archive page that display all posts by the selected author. Not the profile page. (see the second list in the sidebar here: http://www.saftogvann.com/sosionautene/ )
As it is now, both lists (the one in the navbar and the one in the sidebar) links to the profile page. What I want is a tag to use in the sidebar that gets a list of all authors but links to a page that uses the archive template.
1. When clicking on a link in the authors list in the navbar, you should get a profile page displaying information on that author. (This I have acomplished)
2. When clicking on a link in the authors list in the sidebar, you should get a page containing all posts by that author. Just like when you click on a category.
Whas this easier to understand? Thanks a lot anyway.
Well I now understand what you’re looking to do. However, based strictly on the way you lay it out, I’m not sure how it can be done in WordPress without changes to the core, or building a full work-around solution.
Basically at issue here:
WordPress is all about hierarchy when it comes to theme templates. With an author query, it checks for the author template (author.php). When it’s not there, it moves to the next template in the hierarchy (in this case archive.php). This can be bypassed and another template substituted at any point, but to have an author template while using something other than that for your secondary ‘just the posts’ display on author queries, requires a method of notifying WordPress (or a plugin, or whatever) an alternative template is desired before overriding the default template handling.
For ‘notification’ typically with links it’s handled through a GET query. An example of a GET is:
(Note that custom permalinks providing a *virtual* directory like /author/foo just hide the GET string.)
WordPress knows ‘author_name’ (or ‘author,’ which passes the user ID) equals author template. A way to fool WordPress into using the archive template is to append an archive-related query var (variable) to your GET:
(/author/foo/?year=2005 works as well)
Again it’s about hierarchy: author queries default to the archive template (if author.php does not exist), so the archive template trumps author in the hierarchy. Problem here is, you can only specify a range of posts by date. There’s no way to call *all* posts and retain the archive template.
We could create our own GET var, let’s say ‘view’:
Now we can write a plugin which looks for the ‘view’ GET query var, and when its value is ‘archive’ reset the template in use for the author query to archive.php. Simple, right? To a degree it is, but WordPress as a whole will not be aware of this query var of yours. It won’t know to attach it to next/previous pagination links and the like. If you display all of an author’s posts on a single page this may be enough. But if not… And the author links will either need to be added manually, or a separate function written to provide the appropriate query.
Any way you go about this probably require some compromise. So if I might modify your request, here’s another possible way to do what you want:
Allow the author.php template to display just posts (or posts with a small amount of author data). Then within a Page (i.e. Write > Write Page) set up your author profiles. The profiles can be entered into the Page content manually, but a better method is to use a Page template that calls the author profiles dynamically. As it happens, I’ve already written such a template.
All Authors Page Template for WP 2.0 here:
All Authors Page Template discussed here:
The template could even be fancied up to display only one author profile at a time through use of a custom GET query as mentioned above (would require some mods to the Page template’s source, of course). So a link of say:
would tell the Page to display only the profile of ‘foo.’ I think this comes close to what you’re looking for.
- The topic ‘list all posts of one author’ is closed to new replies.