# Show Excerpts Instead of Full Posts on Archives

> Shows a short excerpt and a "Read more" link for each post on the blog page, archives and search results, for themes that print the full content of every post.

- Type: PHP
- Runs: Frontend only
- Category: [Content](https://wpide.com/library/category/content/)
- Tags: excerpts, archives, blog
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/excerpts-on-archive-pages/

## Code

```php
add_filter( 'the_content', function ( $content ) {
    if ( is_singular() || is_feed() || ! in_the_loop() || ! is_main_query() || doing_filter( 'get_the_excerpt' ) ) {
        return $content;
    }

    static $running = false;

    if ( $running ) {
        return $content;
    }

    $running = true;
    $excerpt = get_the_excerpt();
    $running = false;

    return '<p>' . esc_html( $excerpt ) . '</p><p><a class="more-link" href="' . esc_url( get_permalink() ) . '">Read more<span class="screen-reader-text"> about ' . esc_html( get_the_title() ) . '</span></a></p>';
}, 1 );
```

## Notes

The excerpt length and the link text follow your excerpt settings and other excerpt snippets.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Show Excerpts Instead of Full Posts on Archives" 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/
