WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] How to retrieve the content of a page only

[Resolved] How to retrieve the content of a page only

  • Hi guys, for my blog I created my own template and I want to stuff it up with goodies like scriptaculous or dojo (haven’t choosen yet). I want to show the content of a page only. So no html, no head, no body and no side bar etc. just the content. How can I get the content of a page. I don’t know anything about PHP.

Viewing 4 replies - 1 through 4 (of 4 total)
  • If you really want just the content of a page (in the WordPress sense of “page”), then create a page.php template file in your theme’s directory with the following content:

    <?php
    the_content();

    Yep, that’s it.

    I have read that tutorial. But the problem is that in wp 2.7 I don’t see how I can assign a template to a particular page.

    If you want to assign this template to a particular page, then you need to amend it as so:

    <?php
    /*
    Template Name: Pure Content
    */
    the_content();

    and choose “Pure Content” under Attributes > Template when editing a page.

    Yes it worked. Thank you so much for your help. I copied the page.php. Gave it a new name and removed the html wrapper. It looks like:

    <?php
    /*
    Template Name: Page only no html
    */
     ?>
    
     <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    		<h1 id="post-<?php the_ID(); ?>"><?php the_title(); ?></h1>
    
    		<?php the_content("__('[...]')
    "); ?>
    
    	<?php endwhile; endif; ?>

    If you add a template wordpress sees that you have multiple templates and you can pick one from a drop down list. Isn’t wordpress just amazing?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Resolved] How to retrieve the content of a page only’ is closed to new replies.