My guess is that single-template.php
uses the_content
. Now think about what happens:
- Your filter causes
single-template.php
to load single-template.php
usesthe_content
- So
single-template.php
loads again - Which uses
the_content
- Which loads
single-template.php
- Which uses
the_content
- …
I am not entirely sure how to fix that, as your question is light on detail. It is hard to tell what most of the code does or what your ultimate goal is, but it may be as simple as removing the filter conditionally:
add_filter( 'the_content', 'change_single_content' );
function change_single_content($content){
global $post;
if ( 'my-CPT' == get_post_type() && is_single() ){
remove_filter( 'the_content', 'change_single_content' ); // this !!
ob_start();
include my_plugin_theme('single-template.php'); //include single template content
return ob_get_clean();
}
return $content;
}
I am also pretty sure that what you are doing is the wrong way, or at least a less-right way, to do what you are trying to do. I can’t prove that, but my spider sense is tingling something awful.