Plugin API/Filter Reference/the content

Contents

Description

The "the_content" filter is used to filter the content of the post after it is retrieved from the database and before it is printed to the screen.

A plugin (or theme) can register as a content filter with the code:

<?php add_filter( 'the_content', 'filter_function_name' ) ?>

Where 'filter_function_name' is the function WordPress should call when the content is being retrieved. Note that the filter function must return the content after it is finished processing, or site visitors will see a blank page and other plugins also filtering the content may generate errors.

filter_function_name should be unique function name. It cannot match any other function name already declared.

Examples

Debug Page

This could be used to provide generated content for a page (as an alternative to the Shortcode_API), or for a set of pages sharing some characteristics (e.g. the same author):

Post Icon

This filter function adds an image before the post on the post page (see is_single()). It assumes an image named post_icon.png exists in the theme images folder. It runs at a lower priority (20) which runs later than most other filters (default is 10).