WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using get_the_title(453) and while the title displays, i am unable to display the content and the excerpt for the page with the id of 453. The following is my code

    $content = get_the_content();
    echo $content;

Is there is something i am missing or doing something wrong?

share|improve this question
up vote 1 down vote accepted

I figured it out myself and it worked. Here is the code if anyone need any help.

$the_query = new WP_Query('page_id=1') ;
if ( $the_query->have_posts() ) {
while ( $the_query->have_posts() ) {
} else {
    // no posts found


This is working because the_content() and the_excerpt() have to be used within The Loop.

share|improve this answer

if you are trying to output only specific page title and content with looping, it is ok, you just only need id of post or page // Here is two thing you just need to understand 1. the_title() ( no need "echo", this function is more specific for title of current view post or page); 2. get_the_title( need "echo", this function can show every post or page title in every page);

echo get_the_title(120); // 120 is your post or page id, it can show every page
echo get_the_title($post->ID); // for only current page view
echo get_the_title(get_the_ID()); // for only current page view, also in loop
echo get_the_title(get_the_ID(12)) //120 is your post or page id, it can show every page
echo get_the_title(get_the_ID($post->ID));

the_content() is only for current page, also in loop, no need echo 

echo get_the_content(120); // 120 is your post or page id, it can show every page
echo get_the_content($post->ID); // for only current page view
echo get_the_content(get_the_ID()); // for only current page view, also in loop
echo get_the_content(get_the_ID(12)) //120 is your post or page id, it can show every page
echo get_the_content(get_the_ID($post->ID));
share|improve this answer

get_the_title will only retrieve the title of the post you designate. That post data will not carry on to other template tags.

Edit: http://codex.wordpress.org/Function_Reference/get_post should help.

 $post_id = 73;
 $queried_post = get_post(69060);
<h1><?php echo $queried_post->post_title; ?>
<p><?php echo $queried_post->post_content; ?></p>
share|improve this answer
it didn't work. – Nofel Nov 15 '13 at 21:02
And it clobbers the main query. Please, please everyone... stop using query_posts. – s_ha_dum Nov 15 '13 at 22:01
s_ha_dum is right. You should always avoid using query_posts. See here: wordpress.stackexchange.com/q/1753/38536 – psorensen Nov 16 '13 at 13:32
And here: – s_ha_dum Nov 16 '13 at 14:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.