WordPress the_author_posts() Function

Beginner
4 min read
Updated: Nov 2026
3 examples
Template tag

Definition

In WordPress, the_author_posts() prints the number of posts written by the author of the current post. Use it inside The Loop.

It counts posts of the same post type as the current post. To get the number as a value, use get_the_author_posts().

Syntax

Call it with no arguments where you want the number to appear.

WordPress
the_author_posts();
$count = get_the_author_posts();
CallWhat it does
the_author_posts()Prints the number of posts by the current post author.
get_the_author_posts()Returns the same number so you can use it in code.

No echo is needed for the_author_posts().

Full declaration
WordPress
the_author_posts(): void

Parameters

ParameterDescription
NoneThis function takes no arguments. It reads the author of the current post.

Return Value

Return ValueDescription
void (prints to the page)The function prints a number. Its twin get_the_author_posts() returns it as an integer.

WordPress Examples

Three short theme examples. Each one has a sample output.

Example 1 — Basic count

Print the number of posts.

WordPress
<?php the_author_posts(); ?>

How It Works

  1. WordPress counts posts by the current author.
  2. The number is printed.
  3. Nothing else is added.

Example 2 — In a sentence

Use the number inside a short message.

WordPress
<p>
  <?php the_author(); ?> has written
  <?php the_author_posts(); ?> posts.
</p>

How It Works

  1. the_author() prints the name.
  2. the_author_posts() prints the count.
  3. The words around them are your own text.

Example 3 — Use get_the_author_posts() for a check

Return the number when you want to use if.

WordPress
<?php
$count = get_the_author_posts();
if ( $count > 10 ) {
  echo 'Top author';
}
?>

How It Works

  1. get_the_author_posts() returns the count.
  2. The if checks if it is more than 10.
  3. You cannot do this with the_author_posts(), because it only prints.

Frequently Asked Questions

It prints the number of posts written by the current post author.
Use get_the_author_posts(). It returns the count.
It counts posts of the same post type as the current post.
No. It prints only a number. Use the_author_posts_link() for a link.
No. It needs a current post.

Next: the_author_posts_link()

Build a select box of users for forms and admin screens.

the_author_posts_link() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

9 people found this page helpful