Koekjes van dijk Koekjes van dijk - 1 year ago 63
PHP Question

Wordpress using add action 'the content' deletes all pages content

I am using:

add_action('the_content' , 'statistics_page');

And in the function 'statistics_page' I put:

if(is_page(25)) { //blabla }

This perfectly works on the page I want it displayed on (25) but all other pages have their content stripped, they don't display anything.

How can I fix this?

EDIT: extra info

Website link: http://pauldekoning.com/wot

Youll see that Home doesnt display text, nor does the forum page have a forum.

Only the statistic page displays something.

Answer Source

the_content is a filter so you should you apply_filter instead of add_action and you've to make sure you return the actual content from the function. Try after updating your code to following.

apply_filters('the_content' , 'statistics_page');

function statistics_page($content){

    if(  is_page(25) ) { 

    return $content;

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download