It's a weird problem that looks like to have something todo with the WP SEO plugin from Yoast. If I disable it ( and no other plugins are running ), the output is what I expect it to be.
It shows the content of the page that I added in the post editor, together with the content of the included file.
But if the WP SEO plugin is active, then it still shows the content from the post editor followed by 1. The content from the included file isn't there.
I made a very basic demo with code from the codex that on my machine ( in both wp 3.9 and wp 4.0 ) show a 1 instead of the content from the included file. But only is WP SEO from Yoast is active. The code is pretty basic as you can see here http://www.codeshare.io/16KHK
Does anyone have an idea why this would break it?
$template_content = require_once( plugin_dir_path( __FILE__ ) . 'cpt-template.php' );
While this works fine.
$template_content = 'template test';
If I echo the $template_content after including it, the content is there. So it does find it and loads the content. But somehow when WP SEO is active, instead of returning the data that is clearly there ( echoing shows it ), it just shows 1?
I tried it with different default wp themes as well, and it all results in the same thing.
Any ideas what this could be? If someone could maybe try the this code http://www.codeshare.io/16KHK as well and verify it's not just my machine where it breaks if the WP SEO plugin is active?
cpt-template.php
contain? if it doesn'treturn
anything, thenrequire_once
returns1
, meaning the include succeeded. if you want to include a file that outputs content directly, you have to use an output buffer.