# Noindex Posts Below a Word Count

> Adds noindex to blog posts with fewer words than a minimum, such as quick updates or link posts, so thin pages do not drag down how search engines see your site.

- Type: PHP
- Runs: Frontend only
- Category: [SEO](https://wpide.com/library/category/seo/)
- Tags: noindex, thin-content, posts
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/seo-noindex-short-posts/

## Code

```php
// Post types checked and the minimum number of words.
$wpide_thin_types     = array( 'post' );
$wpide_thin_min_words = 250;

add_filter( 'wp_robots', function ( $robots ) use ( $wpide_thin_types, $wpide_thin_min_words ) {
    if ( ! is_singular( $wpide_thin_types ) ) {
        return $robots;
    }

    $content = (string) get_post_field( 'post_content', get_queried_object_id() );
    $words   = str_word_count( wp_strip_all_tags( strip_shortcodes( $content ) ) );

    if ( $words < $wpide_thin_min_words ) {
        $robots['noindex'] = true;
        $robots['follow']  = true;
    }

    return $robots;
} );
```

## Notes

Change the post types and minimum. The count ignores HTML and shortcodes.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Noindex Posts Below a Word Count" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
