• Resolved lookazd

    (@lookazd)


    Hy

    Would like to know is there a way to sort Authors dropdown list in post editor in the way that first it displays original authors (users) and after that it displays guest authors?
    Right now it sorts them alphabetically and mix both users and guest authors together like in this screenshot.

    Also is there a way to remove some created users from the dropdown list?
    For example in the screenshot above, I would like the original user E.M. to not be displayed in this dropdown list in post editor.

    tnx!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Molongui

    (@molongui)

    Hey @lookazd,

    Thanks for reaching out! Let’s get to it:

    List order

    There is no way to get it sorted that way, but following your request, we have added a filter so you can have it. It will be available from version 4.7.8, which will be released soon. You just need to add this snippet in your site:

    add_filter( 'authorship/get_authors/dont_sort', '__return_true' );

    You can add the snippet right away, but remember it will only take effect when you update to version 4.7.8.

    List exclusion

    You have two options here:

    1. Go edit those authors you don’t want to be displayed in the dropdown select and check the “Archive” option for that user. This will prevent the author to be listed in the dropdown (and other places like in the author list displayed by the [molongui_author_list] shortcode that is available in the Pro version of the plugin.
    2. Add a filter to exclude them from the dropdown list. For this you need to know the ID of the author and use the appropriate filter, depending on whether the author is a WP user or a guest author:
    // Exclude some users from the dropdown.
    add_filter( 'authorship/authors_dropdown/exclude_users' , function()
    {
      return array( '1', '4', '12', '33' );
    });
    
    // Exclude some guest authors from the dropdown.
    add_filter( 'authorship/authors_dropdown/exclude_guests', function()
    {
      return array( '546', '987' );
    });
    Thread Starter lookazd

    (@lookazd)

    Hy Molongui

    So if I understood correctly with the next update this list order issue will be fixed?
    That’s great!
    So will I need to add this code you provided with that new update, or that code will be implemented in the update itself?
    If not where should I insert this code? I would like to avoid any additional plugins like code snippets or something like that just for adding a single line of code, and would like to insert it in the original file in the wp backend file manager if possible. But would like to know in which one.

    For the list exclusion option No. 1 works great!

    tnx!

    Plugin Author Molongui

    (@molongui)

    The upcoming update will allow you to:

    1. Get the list of authors sorted the way you described as long as you include the provided PHP snippet.
    2. Add custom PHP snippets so you don’t need to edit your child theme’s function.php file nor install any third party plugin. However, the snippets you enter here will only be run on your frontend.

    So yes, I’m afraid that in order to add the provided snippet you either need to edit your files or add a plugin that allows you to run custom PHP snippets.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to sort Authors dropdown list in post editor?’ is closed to new replies.