Title: Basic query needed using page id
Last modified: August 20, 2016

---

# Basic query needed using page id

 *  Resolved [matthisco](https://wordpress.org/support/users/matthisco/)
 * (@matthisco)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/basic-query-needed-using-page-id/)
 * Hi folks,
 * Can anyone please tell me how I can setup a page with no header or footer so 
   it just echoes the title and content?
 * Can you please post me some sample code?
 * I’ve like to use wordpress pages with facebook canvas app, so I dont have to 
   update two seperate pages, I just need raw content and no templates.
 * Thankyou

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Thread Starter [matthisco](https://wordpress.org/support/users/matthisco/)
 * (@matthisco)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/basic-query-needed-using-page-id/#post-2375695)
 * I have created a page in the htdocs using this code:
 *     ```
       <?php
       $my_postid = 127;//This is page id or post id
       $content_post = get_post($my_postid);
       $content = $content_post->post_content;
       $content = apply_filters('the_content', $content);
       $content = str_replace(']]>', ']]>', $content);
       echo $content;
       ?>
       ```
   
 * But i get the error:
 * Fatal error: Call to undefined function get_post() in /home/fhlinux150/m/xxxx.
   co.uk/user/htdocs/about.php on line 3
 * Can anyone please help?
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/basic-query-needed-using-page-id/#post-2375715)
 * See creating a [custom page template](http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates)
 *  Thread Starter [matthisco](https://wordpress.org/support/users/matthisco/)
 * (@matthisco)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/basic-query-needed-using-page-id/#post-2375722)
 * Many thanks for your reply.
 * I’ve read through the docs a few times, but I cannot understand how to simply
   echo out the title and content with no other html.
 * The reason I’m asking is I’d like to pull my wordpress pages into a facebook 
   canvas page, which needs to be pointed to a url, [http://www.xx.com?page_id=sample](http://www.xx.com?page_id=sample)
 * I can use the same content for my wordpress site and facebook that way, so I 
   dont have to update two different sites.
 * So if I create a page on my wordpress theme hardcoded with the page id, something
   like this:
 * about.php
 *     ```
       <?php
       $my_postid = 127;//This is page id or post id
       $content_post = get_post($my_postid);
       $content = $content_post->post_content;
       $content = apply_filters('the_content', $content);
       $content = str_replace(']]>', ']]>', $content);
       echo $content;
       ?>
       ```
   
 * But it keeps generating an error saying it cant find the get function.
 * Any sample code/ help very much appreciated.
 *  Thread Starter [matthisco](https://wordpress.org/support/users/matthisco/)
 * (@matthisco)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/basic-query-needed-using-page-id/#post-2375738)
 * Firther progress, I can use this code outside of wordpress to generate posts,
   is there a way I can qeury a page by passing the pageid to it?
 *     ```
       <?php
       // Include WordPress
       define('WP_USE_THEMES', false);
       //exact path for wp-load.php.
       // This file is kept in the root of wordpress install
       require('wp-load.php');
       //Query wordpress for latest 4 posts
       query_posts('showposts=5');
       ?>
       <?php while (have_posts ()): the_post(); ?>
           <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
       <?php the_excerpt(); ?>
   
       <?php endwhile; ?>
       ```
   
 * Thanks again
 *  Thread Starter [matthisco](https://wordpress.org/support/users/matthisco/)
 * (@matthisco)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/basic-query-needed-using-page-id/#post-2375857)
 * Cracked it!!!
 *     ```
       <?php
       // Include WordPress
       define('WP_USE_THEMES', false);
       //exact path for wp-load.php.
       // This file is kept in the root of wordpress install
       require('wp-load.php');
       //Query wordpress for latest 4 posts
       query_posts('page_id=127');
   
       ?>
       <?php while (have_posts ()): the_post(); ?>
           <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
       <?php the_content(); ?>
       ```
   
 * <?php endwhile; ?>

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Basic query needed using page id’ is closed to new replies.

## Tags

 * [Page ID](https://wordpress.org/support/topic-tag/page-id/)
 * [query](https://wordpress.org/support/topic-tag/query/)
 * [simple](https://wordpress.org/support/topic-tag/simple/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 5 replies
 * 2 participants
 * Last reply from: [matthisco](https://wordpress.org/support/users/matthisco/)
 * Last activity: [14 years, 6 months ago](https://wordpress.org/support/topic/basic-query-needed-using-page-id/#post-2375857)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
