Genesis Users Page Template

This code creates a page template which you can use to display any users using any of the parameters included in the get_users function.

In this example, the code generates a list of all users who have published at least 1 post however you can change the parameters to anything you like.

users_template

Installation Instructions

Simply create a new file using a code editor like Notepad++ and add the following code to the file. Save the file as a PHP file.

Name the file anything you like, ( something like page_contributors.php ) and upload it to your child themes root directory.

Related Code


Comments

7 responses to “Genesis Users Page Template”

  1. […] You'll also need to add the CSS and functions code according to the instructions on this post. […]

  2. Cathie Avatar

    Hi there Brad, thank you for sharing this. I’m trying to add a piece of code that it only finds contributors for a custom post type called ‘article’. To count only articles posted and not blog ‘posts’. Can you advise me on how to do this?
    I tried adding ‘post_type’ => ‘article’, to the $contributor_ids array but then got stuck as I don’t know much about customising like this.
    Thanks,
    Cathie.

    1. Brad Dalton Avatar
      Brad Dalton

      Hi Cathie

      1. There is no $post_type parameter for get_users or WP_User_Query so that won’t work.

      Should be added as an enhancement to the WordPress core.

      2. The good news is the code also includes a secondary function named count_users_posts which now supports post types since WordPress 4.1 was released.

      See this line in the template around line 17: [code] $post_count = count_user_posts( $contributor_id );[/code]

      Simply add your post type as the second parameter by replacing $post_type with the name of your custom post type:

      [code]
      $post_count = count_user_posts( $contributor_id, $post_type );
      [/code]

      This is what you will need:

      [code]$post_count = count_user_posts( $contributor_id, ‘article’ );[/code]

  3. thisisarp Avatar

    Hi Brad,

    I’m trying to do this in a widget, basically to create a section on my home page. How can I modify the code to achieve that?

    I’m also wanting to show name (linked to author archive), avatar, bio and 3-4 images (which I’d like to add as custom profile fields). I can figure that out, though any tips or pitfalls to watch out for would be helpful.

    1. Brad Dalton Avatar
      Brad Dalton

      I don’t think the output would be any different in a widget but you could change the hook from genesis_entry_content

      Another option is to modify the genesis featured widgets query $args and use that as a users widget. http://wpsites.net/best-plugins/custom-genesis-featured-posts-widget-you-can-modify-safely/

      1. thisisarp Avatar

        I could just take the function contributors_author_list and turn it into a shortcode and use that, no? (forgive me if that’s a dumb question :))

        1. Brad Dalton Avatar
          Brad Dalton

          Good idea of you want it within the content using the WP Editor.

Leave a Reply

Join 5000+ Followers

Get The Latest Free & Premium Tutorials Delivered The Second They’re Published.