Title: title question
Last modified: August 18, 2016

---

# title question

 *  [spitstatic](https://wordpress.org/support/users/spitstatic/)
 * (@spitstatic)
 * [21 years ago](https://wordpress.org/support/topic/title-question/)
 * I have this page: [http://mguthrie.net/portfolio](http://mguthrie.net/portfolio)
 * Then that has subpages such as this page: [http://mguthrie.net/portfolio/photography](http://mguthrie.net/portfolio/photography)
 * Now, on the main Portfolio page, the h2 displays the title as “portfolio” which
   is correct.
 * But on the photography, the h2 displays the title as “photography”. I know that
   it’s just displaying a title there, but I would rather it still say Portfolio.
 * I would rather not have to hardcode the headers in. Can anyone tell me if there
   is a way to tell subpages to display the parent header but not effect the parent
   pages?

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

 *  [Kafkaesqui](https://wordpress.org/support/users/kafkaesqui/)
 * (@kafkaesqui)
 * [21 years ago](https://wordpress.org/support/topic/title-question/#post-213750)
 * This bit of PHP captures the post ID of the parent Page and (if it exists) uses
   that to query the database for the parent’s title:
 * `<?php rewind_posts();
    the_post(); $title = $post->post_title; $parent_ID = 
   $post->post_parent; rewind_posts(); if($parent_ID) { $title = $wpdb->get_var("
   SELECT post_title from $wpdb->posts WHERE ID = $parent_ID"); } echo $title; ?
   >
 * The multiple instances of rewind_posts() is to avoid conflicting with other post(
   or rather, Page) loops in your template.
 *  Thread Starter [spitstatic](https://wordpress.org/support/users/spitstatic/)
 * (@spitstatic)
 * [21 years ago](https://wordpress.org/support/topic/title-question/#post-213773)
 * Thanks!
 * However, I tried it, and it seems to load extremely slow when I load a page, 
   and when it finally finishes, it goes to the front page instead of the page. 
   The same happens when I try going to a subpage.
 * Any ideas?
 * thanks so much for your help.
 *  Thread Starter [spitstatic](https://wordpress.org/support/users/spitstatic/)
 * (@spitstatic)
 * [21 years ago](https://wordpress.org/support/topic/title-question/#post-213774)
 * I’m going to temporily put ‘<?php the_title(); ?>’ back for now.
 *  Thread Starter [spitstatic](https://wordpress.org/support/users/spitstatic/)
 * (@spitstatic)
 * [21 years ago](https://wordpress.org/support/topic/title-question/#post-213776)
 * I figured out a way!
 * `<h2><?php if (is_page('photography')) { echo "portfolio"; }
    elseif (is_page('
   design')) {echo "portfolio"; }  elseif (is_page('other')) {echo "portfolio"; }
   else {the_title();} ?></h2>
 *  Thread Starter [spitstatic](https://wordpress.org/support/users/spitstatic/)
 * (@spitstatic)
 * [21 years ago](https://wordpress.org/support/topic/title-question/#post-213782)
 * Note: I know it’s not very convenient having to put an instance in for each page,
   but it’s the only way I knew how to get this done in the time I needed it done.
 * Please continue to share, however, if you have a better method.

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

The topic ‘title question’ is closed to new replies.

## Tags

 * [parent](https://wordpress.org/support/topic-tag/parent/)
 * [rewind_posts()](https://wordpress.org/support/topic-tag/rewind_posts/)
 * [subpage](https://wordpress.org/support/topic-tag/subpage/)

 * 5 replies
 * 2 participants
 * Last reply from: [spitstatic](https://wordpress.org/support/users/spitstatic/)
 * Last activity: [21 years ago](https://wordpress.org/support/topic/title-question/#post-213782)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
