Koekjes van dijk Koekjes van dijk - 9 months ago 46
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;