0

I use this function to filter some posts content:

function frontend_wizard_content($content){

    if ( !is_page(213) ) return $content;

    ob_start();
    locate_template('mycontent.php', true);
    $wizard = ob_get_clean();

    //print_r($wizard); //works (prints what I want to)
    //return "foo"; //works
    //return $wizard; //does not work
    return $wizard . $content //does not work (returns only initial content)
}


add_filter( 'the_content','frontend_wizard_content');

I can't understand why, but I don't get the $wizard variable outputted. I did notice that this only happens when Jetpack is enabled.

EDIT Seems that this is not related to the_content filter:

My function uses locate_template( $template_names, $load, $require_once ). By default, $require_once is true.

It seems that Jetpack already calls my filter upstream, since when I set $require_once to false, I GOT my output. Not very handy though.

Any advices on this ?

Thanks !

  • from where comes the variable $this at the first test ? – mmm Dec 28 '17 at 20:18
  • Mhh I made the function simpler for the example, but it is defined. – gordie Dec 28 '17 at 22:35
  • require_once does not relate to calling the filter but including the template. i don;t understand why this is an issue either way, though, if you are getting your output. – inarilo Dec 29 '17 at 10:44
  • The problem is that my code (my plugin) does not react the same way when Jetpack is enabled or not, which makes me think that there is some logical problems in their code. – gordie Dec 29 '17 at 12:35
  • @gordie Have you tried setting a priority on your add_filter? JetPack is a highly developed plugin, so I'm guessing the problem is in your code, not theirs. – disinfor Jan 1 '18 at 18:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.