我正在创建一个插件,因为该插件激活了一个名为“文档”的“自定义帖子类型”也创建了一个名为“文档”的页面 .
现在我希望每当“文档”页面被查看时,它应该完全显示我的自定义php页面 . 我不想要wordpress页眉,页脚等 .
我希望这个页面完全在我的手中 . 我尝试使用短代码,我创建了短代码并将其放在页面内容中但是当查看此页面时,它显示了带有worpress主题布局(页眉,页脚)的短代码内容 .
以下是我的代码 .
function documentation_fun( $atts ) {
ob_start();
include 'documentation.php';
return ob_get_clean();
}
add_shortcode( '3pane-documentation', 'documentation_fun' );
我在我的插件中创建了这个 . 请告诉我实现目标的最佳方法 .
EDIT
我还发现了其他内容,内容有一个过滤器
function magicalendar_get_event_page( $content ) {
global $post;
if ($post->post_title == ' Documentation') {
$single_template = dirname( __FILE__ ) . '/documentation.php';
}
return $single_template;
}
add_filter( 'the_content', 'magicalendar_get_event_page' );
但这只是返回文件路径而不是文件(html)的内容 . 页眉和页脚仍然会出现,我不想要 .
我自己找到了钩子:)它是add_filter('taxonomy_template');
谢谢!
1 回答
如果要删除页眉和页脚,请创建自定义页面模板 . 最好的选择 .
创建模板文件 .
最后在页面中选择此模板 .
所以它不会打印页眉和页脚 .
它只会在你打电话时打印页眉和页脚 .
如果没有,那么它将仅使用自定义页眉和页脚输出您的内容 .