Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

How does WordPress convert raw data from the database to a readable format in the_content function?

I've noticed that it applies the_content filter, but what does the_content filter do?

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

the default filters are set in /wp-includes/default-filters.php;

for 'the_content' this is from line 135:

add_filter( 'the_content', 'wptexturize'        );
add_filter( 'the_content', 'convert_smilies'    );
add_filter( 'the_content', 'convert_chars'      );
add_filter( 'the_content', 'wpautop'            );
add_filter( 'the_content', 'shortcode_unautop'  );
add_filter( 'the_content', 'prepend_attachment' );

to trace the individual functions, you could try and use http://phpxref.ftwr.co.uk/wordpress/nav.html?_functions/index.html then follow the links...

Edit

Missed one (wp-includes/default-filters.php, line 102):

// Format WordPress
foreach ( array( 'the_content', 'the_title' ) as $filter )
    add_filter( $filter, 'capital_P_dangit', 11 );
share|improve this answer
add comment

All filters are stored in the global $wp_filter variable. You can inspect that variable to see which functions are bound to a certain filter.

global $wp_filter;
print_r($wp_filter['the_content']);

To exactly understand the array that gets outputted, knowing how the $wp_filter variable is built up helps a lot. This line is from the source of the add_filter() function:

$wp_filter[$tag][$priority][$idx] = array('function' => $function_to_add, 'accepted_args' => $accepted_args);
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.