I think what you’re after is:
// The user is logged, retrieve the user id (this needs to go above your foreach)
$user_ID = get_current_user_id();
// Now we have got the user's id, we can pass it to the foreach of your function(this needs to go into your foreach:
echo '<li>Number of '.$post_type->name.' posts published by me: ' . count_user_posts( $user_ID , $post_type->name ).'</li>';
Related Posts:
- Displaying Custom Post Types In “At A Glance” Meta Box
- right_now_content_table_end function not working?
- Display author box on just certain category posts?
- how to display author name in custom post type
- Limit custom post type to the authors only on front-end!
- Why is wp_list_authors not picking up Authors from CPT’s?
- How come Featured Image isn’t showing up in my Custom Post Type?
- How to use a custom post type archive as front page?
- Set posts of a custom post type to be private by default?
- clients list using wordpress
- Find callback function for custom taxonomy metabox
- Date archives for custom post type
- How can I add dropdown widget/box to admin post page?
- Limiting number of custom posts shown on taxonomy page
- How to Change the Title of a Meta Box on a Specified Custom Post Type? [duplicate]
- Append taxonomy terms as class names in markup?
- Prevent author role from editing all posts in custom post type?
- How to get Custom Post ID by adding filter to child theme’s function
- WP-Admin edit.php & post.php slowdown after import of 10k users
- Loop through posts of a custom-post-type (event) and create .ics (iCal) file?
- When ‘is_post_type_archive()’ return true?
- How to add the post ID (or any other post data) to a Contact Form 7 mail?
- How To Enable Block Editor (Gutenberg) for Existing Post Type via functions.php
- How Can I Set the Post Author of a Post I Just Created With PHP?
- Custom Post Type and Labels
- Create a post in custom post type using field in registration form after users submit form
- Notice: Undefined index: suppress_filters
- I did group my search results by post type, but how can i give each of them its own order?
- Change custom post type slug from plugin options
- How to target a specific custom post type post and its all children and grandchildren?
- ACF field key/value to show on taxonomy list
- Re-registering a custom post type not working (not showing up)
- Query taxonomy of taxonomy of custom post type
- Edit the author of custom post type
- Homepage’s content is dependent on the custom field values (set automatically), how do I get homepage to update without manually updating page?
- How to change permalink to include custom post type
- Configuring a meta query with multiple post types that have the same relationship on a single page
- Add term to custom post type on draft
- Global custom meta box
- Template not working for the custom Post type
- PHP question: how to combine syntax?
- ACF in wordpress
- Change Slug of a Custom Post Type
- How to inherit field value from parent post into in child / sub post
- Custom post type’s posts are not showing anywere but in xml sitemap
- Get current user id
- Show current user posts in custom post type query
- Rewrite permalink for multiple post types (CPT) with taxonomy term
- Custom post type in Custom widget – $listItem
- Add data to post edit page, when post is published
- Custom posts – tag pagination
- Adding custom post formatting options in custom post types
- Custom meta box in custom post type not working
- get post count for related author
- Function to add custom HTML into head in custom post-type list page
- Adding link to dashboard sidebar, nested under custom post type
- Submit Custom Postypes from frontend
- Need help with Custom Post Types and Taxonomies
- Conflict in function to allow single post template based on category
- Showing only posts from the current user who is logged in?
- set object terms after some some time of published post – functions.php
- Is there a way to use ‘publicly_queryable’ => false only on specific taxonomy term?
- Pagination not working in custom post type. Help
- How to add specific terms in a custom post type?
- Urgent – WordPress keeps creating posts
- Create posts inside CPT post
- Problem with multi checkboxes value in metabox?
- Send mail to author when custom post type is saved
- Recovering data about custom post and taxonomy types
- Need to display author’s email id in the “Edit post” field in wp dashboard. How do I do this?
- wordpress does not see the correct custom taxonomy hierarchy
- is using “require_once” in wordpress theme affect the speed ???
- How to make id user can be view content
- Custom permalink rewrite rules – how do I fix this?
- Display posts on parent post if author coincides
- Populate custom post type/custom fields from an external database
- How to sort custom post’s category by id from the theme’s function.php?
- Work and Display a Custom Post Type as a normal Post
- Custom Field to post_title
- Custom user roles
- Post Custom & Taxonomy 404 error
- How To Display Category list from Portfolio post type plugin?
- Create 2-layered dropdown menus for custom taxonomy and custom post type
- Get author image for posts in loop on custom type posts page
- WP_Query function for custom post type
- Modify shortcode to work with custom taxonomies and slugs
- Calling the first & last post by category in custom post type
- Query custom post type and showing its content
- WordPress Author Posts Review After Every Change In The Same WordPress Post
- Custom Post Type Author Array Problem
- Author template – separate custom post type by custom taxonomy term for $curauth
- Allow authors to create article image
- empty dashboard for custom role
- Code in custom widget queries all posts, when it should only query the current post
- How is get_the_author connected to a custom post type?
- Comments are not working on Custom Post Type
- How to make a non-public post on wordpress approval?
- how to display custom taxonomies in front page
- wordpress category form fields in popup
- How to display *block number* instead *date value* on WordPress posts?