Support » Plugin: Simple User Listing » Custom Post Type Count?

  • Hi,

    I was wondering if it’s possible to do what this shortcode was doing (how you have it in the FAQ):
    [userlist orderby=”post_count” order=”DESC”]

    except we display the descending list based on user-submitted posts (a custom post type) as opposed to the regular post type.

    Thanks

    The page I need help with: [log in to see the link]

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

    (@helgatheviking)

    This plugin supports only what is possible with WP_User_Query, see the Codex for full info. But it does appear that the has_published_posts parameter may be relevant, and is not included in SUL. I can’t do a full test on it now.

    But something like this may help:

    [userlist number="5" query_id="product_authors"]

    And then manually add the product type support:

    
    function kia_filter_by_cpt( $args, $query_id ) {
        if( $query_id == 'product_authors' ) {
            $args['has_published_posts'] = array( 'product' );
        }
        return $args;
    }
    add_filter( 'sul_user_query_args', 'kia_filter_by_cpt', 10, 2 );
    

    I don’t know if that will work exactly as you need, but it’s hopefully a start. I’ll try to add support for that eventually, but this is one of my free plugins and so I can’t prioritize work on it.

    Cheers!

    Plugin Author helgatheviking

    (@helgatheviking)

    @jtcheng I’ve just added support for has_published_posts in a developmental version of the plugin here: https://github.com/helgatheviking/Simple-User-Listing/tree/feature/loop

    Would you check it out and see if it works for you? The shortcode attribute value would be a comma-delimited list of post types.

    [userlist has_published_posts="custom-post-type,posts,products"]

    Keep in mind you would still need to customize the templates output to show a different count and a different link. but you can use the template attribute to assign a unique template when displaying a directory based on a custom post type.

    [userlist has_published_posts="custom-post-type" template="custom-author"]

    And then instead of the content-author.php template, the plugin would load content-custom-author.php from your theme’s simple-user-listing/ directory.

    Also, remember this is a developmental version and you should test it extensively before using it in production. Please let me know if it works for you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom Post Type Count?’ is closed to new replies.