admin管理员组文章数量:1025481
In a plugin I want to display a specific page without redirecting (and thus without changing the URL) like the plugin / does. I can capture 404s and redirect them, but I want the URL to stay the same when I show a custom page.
// A. this only displays the content and the not the header, footer, or title.
$post = get_page_by_path('/some-page/');
$content = apply_filters('the_content', $post->post_content);
echo $content;
...
// B. This only displays the page template, but doesn't include the content.
$template = get_template_part('page');
echo $template;
...
// C. A combination of the two doesn't include the sidebar or the or the page title.
$template = get_template_part('header', 'custom-404-page');
echo $template;
$post = get_page_by_path('/custom-page/');
$content = apply_filters('the_content', $post->post_content);
echo $content;
$template = get_template_part('footer', 'custom-404-page');
echo $template;
... I also tried:
// D.
global $post;
$post = get_page_by_path('/custom-404-page/');
setup_postdata($post);
$template = get_template_part('page');
echo $template;
but the content of the page still doesn't appear in the basic page template.
thanks
In a plugin I want to display a specific page without redirecting (and thus without changing the URL) like the plugin / does. I can capture 404s and redirect them, but I want the URL to stay the same when I show a custom page.
// A. this only displays the content and the not the header, footer, or title.
$post = get_page_by_path('/some-page/');
$content = apply_filters('the_content', $post->post_content);
echo $content;
...
// B. This only displays the page template, but doesn't include the content.
$template = get_template_part('page');
echo $template;
...
// C. A combination of the two doesn't include the sidebar or the or the page title.
$template = get_template_part('header', 'custom-404-page');
echo $template;
$post = get_page_by_path('/custom-page/');
$content = apply_filters('the_content', $post->post_content);
echo $content;
$template = get_template_part('footer', 'custom-404-page');
echo $template;
... I also tried:
// D.
global $post;
$post = get_page_by_path('/custom-404-page/');
setup_postdata($post);
$template = get_template_part('page');
echo $template;
but the content of the page still doesn't appear in the basic page template.
thanks
本文标签: templatesDisplay a custom 404 page without a redirect
版权声明:本文标题:templates - Display a custom 404 page without a redirect 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745630443a2160130.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论