Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Show number of posts by logged in user

Here a code example with explanation in the comments:

// First a check whether the use is logged in or not:
if ( is_user_logged_in() ) {
   // The user is logged, retrieve the user id
    $user_ID = get_current_user_id(); 
   // Now we have got the user's id, we can pass it to the function 'count_user_posts':
    echo 'Number of posts published by user: ' . count_user_posts( $user_ID );
} else {
    //  The user is not logged in
}

Related Posts:

  1. Gather posts into a cart/lightbox and share with another user
  2. Retrieve data from post meta meta_key having ‘_product_fq_image’ while having author_id and post type is PRODUCT
  3. How to check if post meta key exists or not in wordpress database
  4. Update post counts (published, draft, unattached) in admin interface
  5. How to add category to: ‘wp-admin/post-new.php’?
  6. How to Display a List of Users Who Have Made at Least 1 Post?
  7. Find out who deleted a page or post?
  8. How can I retrieve multiple get_post_meta values efficiently?
  9. Code to make a post sticky
  10. How to allow hidden custom fields to be added from wp-admin/post.php?
  11. Export WordPress Posts and Meta Information in CSV format
  12. WordPress: How to get the current logged in author page URL?
  13. Delete duplicated wp_postmeta record
  14. disable password protected page for logged users
  15. Will a large postmeta table slow a site down?
  16. Update all posts automatically when using post_meta
  17. How to batch update post content with custom post meta value
  18. Change slug with custom field
  19. Force “Submit to review” when a post is updated
  20. Better post meta efficiency?
  21. Setting post meta data to random value during post status transition / on publish
  22. Edit meta data does’t work with custom sql
  23. Overview with latest edited posts and pages
  24. Navigation link to specific user page
  25. Show a list of recently viewed posts to a user
  26. Get how many days since last post of the current user
  27. Human Time Diff, change mins to minutes
  28. Change post format using custom field
  29. Hide comments awaiting moderation from user who submitted the comments
  30. Does WP get all post_meta on POST page?
  31. Sanitizing `wp_editor();` Values for Database, Edit, and Display
  32. Query All users that has post
  33. Exporting Data from WordPress into a flat table
  34. Adding Multiple Values to a Post Meta Key
  35. Using radio button meta data from a custom meta box
  36. Limit number of posts a user can make per minute?
  37. How do I allow users to follow a post and then allow admins to email all users who have followed that post?
  38. wp_insert_post let users post to without login…broke
  39. Get user’s most published categories
  40. Allow anonymous users to post to my site for moderation
  41. PHP Notice error (when on 404 page)
  42. What Is meta_id In wp_postmeta?
  43. disable column on post and user list
  44. Checking if a post with certain meta value exists
  45. How to permanently delete a post meta entry?
  46. Add custom field automatically (add_post_meta) with value based on number of words of article
  47. how to find user ids of all commenters in a post
  48. How to list users and their post amount?
  49. How to generate numbers indistinguishable for the IDs of the posts
  50. Is there any way to allow users to access content before it’s published?
  51. UberMenu list current user’s posts as menu items
  52. Modify WP_Post before processing
  53. Save re-arranged draggable post items to wordpress database
  54. I would like to give special promotion for the first 100 posts in my blog? Can anyone tell me how to do that?
  55. Change post_date to post_modified date on post template?
  56. Create post for every user?
  57. count the total number of comments the user has received for his published posts
  58. Converting a dynamic piece of code using WordPress Loop into a static one using Post ID
  59. how to delete all users and posts based on ‘user_meta’?
  60. Restrict users post for himself
  61. How to allow logged in users to post anonymously
  62. Allow public to post on blog
  63. How can I sort posts by the date and a custom meta field?
  64. is there a way to show the the post title after the image?
  65. Get Meta Key Value While Saving Post
  66. current post with current author
  67. How to verify wp user password by sql query in wp? [closed]
  68. Force the “Choose from the most used tags” meta box section to always be expanded
  69. How can I get global $post to work for CPT and update user?
  70. Meta value does not save for scheduled posts
  71. Custom Posts Query and meta_query Sort Order
  72. How can i delay reading posing in 3days for not logined user?
  73. Encountering “Wrong nonce. Action prohibitied.” when trying to alter User Role and unable to Post via WP Admin
  74. How to compare two posts including their meta fields on a scalable base?
  75. Getting value from get_post_custom
  76. Users problem (multi-author plus multisite)
  77. Calling Different Custom Post Timestamps in a table
  78. Is it possible to paste a link without tags and make it directly a link in a post?
  79. Cannot retrieve a custom RSS field from posts
  80. Saving custom fields to a custom taxonomy
  81. How to automate featured posts number? [duplicate]
  82. How do I manage my users post before publish?
  83. How do I retrieve a users’ last 5 posts?
  84. cannot get user_registered date from get_user_meta
  85. Customize rel=canonical tag for single blog post
  86. Change all author links in Blog roll
  87. How to I retrieve the ID from the Posts page?
  88. How to save meta checkbox WordPress
  89. Assign published posts to another user automatically
  90. How to calculate the average of a post meta value(Numeric) of a specific author
  91. Is there any way to tell when wp_postmeta has been updated?
  92. Add field to user meta table in database when link is clicked
  93. Hide comments and posts posted by other user
  94. Automatically create a default set of posts for each new registered user
  95. wpColorPicker – problem with implementation to post meta
  96. Summary of Posts by an User
  97. Change post author without using wp_update_post()
  98. Display a list of users who have viewed the post you are viewing
  99. if in category but only with post meta
  100. Check if current user has a post and that post has any term/s from a specific custom taxonomy outside the loop
Categories posts Tags post-meta, posts, user-meta, users
WP Ubuntu/Mac image conversion differences
Gravity Forms merge tags in templates?

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress