当前位置: 动力学知识库 > 问答 > 编程问答 >

Wordpress show post without widgets, header, footer

问题描述:

We use Wordpress for the company blog. We would like to show some of the posts in a popover (or light box) on another website. To do that, we need to be able to show just the post's contents without the widgets, header, footer, etc.

So, for example, look at this post:

http://wordpress.org/news/2014/07/wordpress-4-0-beta-1/

Imagine being able to use a special URL, like http://wordpress.org/news/2014/07/wordpress-4-0-beta-1/?postOnly=true where the top header would be removed (the black stuff), all the widgets on the side bar, the entire footer, etc.

Only thing remaining would be the headline, when posted and by who, and the actual post contents.

Any ideas?

网友答案:

Create a very simple page template with code similar to this:

<?php 
/*
Template Name: Clean Page Template
*/
wp_head(); 

if (have_posts()) :
    while (have_posts()) : the_post(); 
       the_content(); 
    endwhile; 
endif;

wp_footer(); 

Then just set this template in the post edit screen.

网友答案:

If You can modify theme You're using it's simple to do - just check if postOnly parameter is set and set to true in places that render header, footer etc. If so, simply don't render it.

分享给朋友:
您可能感兴趣的文章:
随机阅读: