WordPress.org

Ready to get started?Download WordPress

Forums

Co-Authors Plus
[resolved] Co Authors Plus and Custom Post Type Counts (4 posts)

  1. kshaner
    Member
    Posted 2 months ago #

    Hi,

    The Co Authors Plus plugin only counts the 'post' post type and doesn't count any custom post types with posts type functionality. I've looked at the co-authors class and it appears that the post type is hard coded at line 532 on the file co-authors-plus.php.

    Is there any way around this limitation without forking the plugin? If not, a feature request would be a filter to allow the types of my choosing to be counted.

    http://wordpress.org/plugins/co-authors-plus/

  2. Daniel Bachhuber
    Hand Built
    Plugin Author

    Posted 2 months ago #

    I'm open to including a filter that allows you to specify multiple post types. My preference is that we could get this to "work better" by default.

    In Co-Authors Plus, we primarily use this number to provide accurate results on the Manage Users view in the admin. By default, core will use count_many_users_posts() (ref) which defaults to post (ref).

    • How would you like to use this number?
    • If you want a count on the Manage Users screen that includes more post types, what would the count link to? It currently links to Manage Posts filtered to the specific author.
    • If the use case is something custom, would a helper function to get an array of post counts be more helpful?
  3. kshaner
    Member
    Posted 2 months ago #

    Hi Daniel,

    Thanks for the reply. My use case for this is being able to see all the authors posts count and link to the manage authors page like it works now but modify the manage posts query when guest_author query var is applied and use pre_get_posts to add the custom post types there as well. Ideally I'd also add the post_type as a column to the manage posts table also.

    The array of post counts could be good if there is a filter to apply the count to the table.

    Ideally, I'd like to set a filter in the theme functions file to define which post_types CAP should work with.

    Seeing though in the wp source that it defaults to only one post type at a time, it would have to be a custom (potentially heavy) count function instead of using count_many_users_posts().

  4. Daniel Bachhuber
    Hand Built
    Plugin Author

    Posted 2 months ago #

    Ok, makes more sense. I'm open to adding a filter which lets you choose which post types are used in the published post count. I'll get that in the next release.

    Because core doesn't really support the rest of your defined use case, I'm going to call that custom development territory for now. It's certainly doable with a bit of custom code, but I don't think it makes sense to include in the plugin.

    Ideally, I'd like to set a filter in the theme functions file to define which post_types CAP should work with.

    You have two approaches to choose from:

    • Co-Authors Plus automatically works with any post types that support author
    • If you only want to have co-authors on a subset of post types, you can filter those post types with coauthors_supported_post_types

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.