Support » Plugin: Simple User Listing » Results are listed before post content

  • Resolved benutzerfreund


    Great PlugIn, thanks a lot.

    I got everything working, except one thing: The author list is listed before the other text on my page.

    I used:

    <h2>Die Autoren unseres Blogs</h2>
    <p>[userlist role="" number="5" orderby="post_count" order="DESC"]</p>

    What I get is this HTML:

    <div class="entry-content">
    					<!-- FIX-jj no search --><div id="user-13" class="author-block">
    	<p>Peter Pan</p>
    <div id="user-3" class="author-block">
    	<p>Hans Hammer</p>
    <div id="user-12" class="author-block">
    	<p>Anja All</p>
    <!-- FIX-jj no pagination --><h2>Die Autoren unseres Blogs</h2>

    What did I get wrong?

    Thanks for your help in advance,

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author helgatheviking


    You didn’t get anything wrong. Apparently I’ve been echoing the shortcode this entire time! #facepalm. Please update, and it will return like a proper shortcode now.

    Thanks for the heads up. I can’t believe no one noticed this sooner.

    Wow, thank you for the super fast answer!

    And now it works like a charm.

    Unfortunately, I ran into some limitations. Maybe you could help me with this… I need a list of all “admin” AND “editor” users, sorted by their last name. Since WP_User_Query doesn’t support returning several roles and doesn’t support sorting by user_lastname, I can’t use your PlugIn for this, right?

    Any other ideas?

    Thanks again,

    Plugin Author helgatheviking


    You’re welcome. WP_User_Query does not support querying for multiple roles, which is a shame. It is something I would consider for a premium version (because there must be a workaround), but I have no immediate plans for that.

    You can probably sort by last name however. I just helped someone in another thread search by display name, so I would guess it is possible if you get the query_where (and maybe sort_by) code right when filtering pre_user_query

    See my code in the other thread:

    It is really a shame. I did a workaround now with a dumb if-clause to exclude some roles now. Not elegant nor fast, but it works for me.

    Thanks again!

    Plugin Author helgatheviking


    I thought I had found the solution here:

    But I haven’t been able to get it to work yet.

    Yes, this works. But it doesn’t solve my sorting problem. So the solution I opt for is

    $args  = array(
        'meta_key' => 'last_name',
        'role'     => ''
    $wp_user_query = new WP_User_Query($args);
    $wp_user_query->query_orderby = str_replace( 'user_login', 'wp_usermeta.meta_value', $wp_user_query->query_orderby );
    $authors = $wp_user_query->get_results();

    Then I go through this list and check if user has the role I just want to show.

    Just in case anyone could use this.

    Plugin Author helgatheviking


    Cool. Thanks for sharing, though I think you can do query_orderby using pre_user_query as currently I think you are querying twice, and it is already a slow query.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Results are listed before post content’ is closed to new replies.