0

I have a multisite with two subsites (sub-domain setup) both sites have the same theme, same plugins but the first one is in Hebrew and the Second in English.

On certain templates (not all) in the English site "the_content()" doesn't work (it works just fine on the Hebrew site). This is on a custom-post-type, but not all CPT's suffer from the same problem, it seems to be rather random as to which post-type doesn't work (but consistent as to the fact that they continue not to work).

I checked everything, the loop seems to be OK (the_excerpt() and the_title() work just fine), but specifically the_content() isn't working (and get_the_content()), the only way that displays the content is $post->post_content. I turned all the plugins off and checked (no effect)

So my workaround for now is

echo apply_filters('the_content', $post->post_content); 

which should supposedly sanitize it correctly (this works). again, same template on the first site works just fine with the_content() (once I applied the workaround, it doesn't use it of course anymore.

I am using roots theme http://www.rootstheme.com/

Can anyone help? What am I missing?

1 Answer 1

1

Check for any filters that only return if certain conditions are met. I had an issue once where almost all my pages' content areas were blank. I found the problem was in a snippet of code that looked like this:

add_filter( 'the_content', 'this_will_blank_pages' );
function this_will_blank_pages( $content ) {
    if( is_page( 'some-page-title' ) ) {
        str_replace( 'some-text', 'other-text', $content );
        return $content;
    }
}

The problem is that the return $content; only happens on some-page-title, which means that on all other pages, there was no return statement. Thus, blanked content areas.

When I modified my code to this:

add_filter( 'the_content', 'this_will_blank_pages' );
function this_will_blank_pages( $content ) {
    if( is_page( 'some-page-title' ) ) {
        str_replace( 'some-text', 'other-text', $content );
    }
    return $content;
}

... it worked as expected. Lesson learned.

Check your theme's functions.php file and any plugins you might be using for filter functions with that kind of logic.

1
  • This answer makes a lot of sense, especially because the way the behavior happens only in certain places on the site, however, I checked this and went over all the instances where the_content() was being manipulated in my theme and plugins, and I couldn't find a single instance of this (where a return doesn't happen). I know this makes my question super localized, but it is still a problem. Commented May 12, 2013 at 11:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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