Skip to content

word-count : Count the words in a website ​

This command counts the words in a website's content, e.g. to estimate the cost of translation. It lists each post with its title, excerpt, content and SEO meta word counts, largest first, so outliers are easy to spot.

The command is read-only and makes no changes to the website.

What is counted ​

  • Post title, excerpt and content
  • Yoast SEO title and meta description, where set
  • String values stored in ACF blocks
  • Any extra post meta keys given with --meta

By default it counts published posts of all public post types (except attachments), plus synced patterns.

Block markup, HTML and shortcodes are stripped. Dynamic blocks (e.g. query loops) are not rendered, so text pulled in from other posts isn't counted twice.

WARNING

Taxonomy terms, menus, form labels and theme/plugin strings are not counted. These will need to be estimated separately.

Multilingual websites ​

On Polylang and WPML websites only the default language is counted, so existing translations are not included. Use --lang to count a different language (a Polylang slug or WPML code).

Post types that aren't translatable are always included.

Running the command ​

bash
# One row per post
wp eighteen73 word-count

# Export a spreadsheet
wp eighteen73 word-count --format=csv > word-count.csv

# Totals per post type
wp eighteen73 word-count --summary

# Only posts and pages, including an ACF field stored in post meta
wp eighteen73 word-count --post_type=post,page --meta=intro_text

# Include drafts
wp eighteen73 word-count --post_status=publish,draft

Output formats are table (default), csv, json and yaml.

TIP

If you have an alias set up you can use this to count a live website as follows:

bash
wp @production eighteen73 word-count --format=csv > word-count.csv