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

On one of my page templates I need to include the contents of several other pages. For example, if my page template is called Fruit, I need to pull in page content from pages named Apple, Pear, Orange, Lime, etc. This gives my user the ability to edit Apple and Lime individually from admin area.
I'm trying to use get_page_by_title() to pull in these sub pages, but that function only seems to want to work once per page. The first time I call


works perfectly. When I later call


it displays Apple again. Is this function limited to once per page, or am I doing something else wrong?

Edit: It seems that no matter what title I pass to get_page_by_title() it will always get the content of the current page. So if I'm on example.com/fruit and call


with in the page, it will always display the content from Fruit. Not Apples.

share|improve this question
up vote 1 down vote accepted

get_page_by_title returns an id not content. here is an example of what I use to get content from a certain page id.

call the function

$page_id = get_page_by_title('title');
$excerpt =  get_excerpt_by_id($page_id);

in functions.php

function get_excerpt_by_id($post_id) {
   global $wpdb;
   $query = "SELECT post_content FROM $wpdb->posts WHERE ID = $post_id LIMIT 1";
   $result = $wpdb->get_results($query, ARRAY_A);
   return $result[0]['post_content'];
share|improve this answer
Great. Thank you very much for the clarification. – Jeff Jul 7 '11 at 19:14
get_page_by_title() returns post' object or one of numeric and associative arrays, containing post information, not post id. – Max Yudin Jul 18 '12 at 11:38

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.