Viewing 10 replies - 1 through 10 (of 10 total)
  • No. The only author-type argument for list_authors() / wp_list_authors() is the parameter to exclude the admin account.

    portalpie

    (@portalpie)

    Hello,

    Is this at least possible? I would like to be able to list Authors on my site this way too. Is it hard to implement?

    Thanks

    Kafkaesqui

    (@kafkaesqui)

    Is this at least possible?

    Of course it’s possible.

    But you’re asking for a replacement of {wp_}list_authors() to output users within a certain role. Here’s a plugin which provides that:

    List Authors By Role plugin
    Download plugin | View source

    Download the plugin file, upload it to your plugins directory, then activate List Authors By Role under Plugins. You can make use of one of two functions (i.e. template tags):

    <?php list_authors_by_role(); ?>
    <?php szub_list_authors_by_role(); ?>

    Both accept the same parameters as their internal WordPress counterparts, but offer an additional one to restrict by role.

    The new parameter in list_authors_by_role() is appended to those for list_authors(). Using szub_list_authors_by_role(), pass the ‘role’ parameter like so:

    <?php szub_list_authors_by_role('role=contributor'); ?>

    Separate multiple roles with a comma:

    <?php szub_list_authors_by_role('role=author,contributor'); ?>

    portalpie

    (@portalpie)

    Ask and ye shall receive.

    Thanks Heaps!

    portalpie

    (@portalpie)

    OK, well that did not go as smoothly as I would have liked.

    I am guessing that this plugin does not work with Role Manager???

    Otherwise I am simply doing something wrong in Sidebar Modules.

    Thanks

    portalpie

    (@portalpie)

    OK, so my php module is working and there is no plugin conflict with role manager, but i still have a problem:

    If I use this code:
    <?php szub_list_authors_by_role(); ?>
    I get nothing. But if I use this code:
    <?php list_authors_by_role(); ?>

    I get a list but I get everyone from all roles. I would like to generate 2 lists, one with a list of Authors and one with a list of Contributors. I think that I may be just miss understanding the explanation above. Could you hold my hand a little longer please?

    Thanks
    Morgs

    Kafkaesqui

    (@kafkaesqui)

    Realized there was a little ‘oops’ in the code that may have caused a problem for you here. I forgot the capabilities (i.e. role) record in the usermeta table made use of the table prefix for the meta_key, so I had hardcoded wp_ as part of the query. This is fixed in the version of the plugin now online (R1.0.1).

    Anyway,

    1. It will work with Role Manager.

    2. Both functions you list above when providing no arguments should list all authors (or whatever) with one or more posts. In other words, it works the same as {wp_}list_authors().

    3. To generate your two lists:

    <?php szub_list_authors_by_role('role=author'); ?>

    <?php szub_list_authors_by_role('role=contributor'); ?>

    portalpie

    (@portalpie)

    Hello Kafkaesqui,

    I finally got it to work. It was my fault. I was using role names with spaces and capitals.

    I think there might be just on little bug in your code. There are no <ul> & </ul> tags. I did try putting them n the loop myself, but not enough skill to make the /ul appear only once.

    Thanks heaps for your help.
    Morgs

    Kafkaesqui

    (@kafkaesqui)

    If there’s a bug, then I merely copied it over from list_authors(). :)

    However, I wouldn’t call this a bug at all. list_authors() (and so by extension, szub_list_authors_by_role()) is one of the few list-displaying template tags that assume it’s being nested in the appropriate HTML element. So you can do:

    <ul>
    <?php szub_list_authors_by_role(); ?>
    </ul>

    portalpie

    (@portalpie)

    Sorry if Bug offended. I am but a mere amateur trying to use the lingo. I completely understand what you mean. I have just learnt something that I will be able to apply again and again.

    Thanks again. Everything works now just how I was hoping it would.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘wp list authors by role’ is closed to new replies.