Based on the comment exchange, here’s what I think you’re after:
<h1><?php echo get_the_title( $post->post_parent ? $post->post_parent : $post->ID ) ?></h1>
<?php if ( $list = wp_list_pages( "echo=0&child_of=$post->ID" ) ) : ?>
<h2>Select a sub-page</h2>
<ul>
<?php echo $list ?>
</ul>
<?php elseif ( $post->parent ) : ?>
<h2><?php the_title() ?></h2>
<?php endif ?>
Related Posts:
- How to get page’s ID if I know the title only?
- How to sanitize post title with commas
- change title separator
- Modify conditional titles to include parent and page number
- Blog Title not showing up on main Blog page
- Replace text in the Title
- Wrap the_title_attribute in a H2 within a Conditional Tag?
- How come I get internal server error even with try catch for get_the_title in functions.php?
- Print title page in header of a specific page
- Show post title words one by one [closed]
- Generate page title tag from the content of H1
- Using php to overwrite or replace title tag, while using yoast [closed]
- Auto Add Image Title,Caption,Alt Text,Description while uploading Images in WordPress
- Changing title of a page dynamically from within a plugin
- Problem in wordpress with “-“
- add_theme_support( ‘title-tag’ ) in conflict with custom titles function
- Show content if parent page has children
- Modify page title format (when using title-tag)
- Empty title on front page/Home
- REQUIRED: The theme must not used the tags. | REQUIRED: The theme must not call to wp_title()
- Delete Child Posts
- How to make a H1 different then the Title?
- How do I edit the tag without using the deprecated `wp_title()` function?
- Only allow new subpages to be created
- Change Default Custom Fields Metabox Name
- Automatically add title attribute to links in WordPress
- How can i remove JUST the title tag from wp_head() function?
- Remove site name from tag
- Change title tag dynamically or within plugin?
- Get title of page from URL
- Filter get_the_title to remove certain characters?
- Change all Post titles into [Title Case] format
- How to modify a title tag in genesis?
- Change Site Title and Description html tags if not home page
- How to Change Title Attribute to be different from Page title
- How to echo a different title to the page if it’s opened on an android mobile phone
- Adding schema.org itemprop to WP4.1 Title Tag
- Set order of returned items in the WP_Query() class/function
- How do I shorten the title lenghs with Elementor theme? [closed]
- WP action/filter to modify title before header output and article output?
- How to Customize “WordPress > Error” Text in Titlebar?
- Changing title & add Breadcrumbs
- Display Child Pages of Custom Post Type Parent Page
- Sanitize the output of the_title() or the_title_attribute() to remove whitespace
- Change page title dynamically before header is rendered
- is_child() function
- For better digital journalism, how to store a second title and excerpt?
- After I set the title, it over-wrote all the titles for the individual pages
- Title tags show twice
- Setting page title and keywords from PHP code
- Anyway to specify what should appear in in .php file?
- How to solve the site tag being displayed twice?
- disallow publish posts with special title
- Print post title with markup
- How to remove Title and CSS styling of title from particular page
- List of child custom post types lists all custom post types
- How can I remove the first two words and shorten get_the_title()
- Double bar “|” in title (By WP SEO Yoast?) [closed]
- Delete a repeated part of post title in WordPress
- how to set alt & title for featured image get_the_post_thumbnail
- How to add publish date in the title
- How to give titles to custom post type as “unique” incremental number?
- Front page displays different than all other pages?
- How to disable publish button if post title exists
- Array to modify post titles
- How do I remove ‘Home’ from homepage title?
- How to set “lang” attribute for post/page title?
- Title don’t function as link
- Enclose title within a div?
- Title how does page no work in Twenty Eleven
- strtolower
- how to change the title of tag page?
- how to add dynamic text before and after of post title
- Add text to the first “title”=>get_the_title($post->ID), and shorten
- Changing Title Tag on Shop Archive Page (current solution reverting to Title of First Product in Loop)
- Get first level children of a page ID
- Modify WordPress Page Title ()
- Title tag on home using front-page template not showing
- Post title not displaying as recorded in the wp_posts table
- Limit title length
- Remove title bar from post-new.php
- Child and Parent Pages list of sub pages
- How to get page title () in a different order?
- Blog Post Title apearing twice
- Setting Page Title Yoast
- How to modify title tag in a plugin?
- How to Implement Category.php page title in wordpress custom template?
- Why I can not modify the appereance of my title web site in google? [closed]
- Need a conditional to test if title of parent page matches title of child page
- Get post title of faulty link on 404 error page
- how to display page title only for child category pages
- Append text after wordpress title
- How to add … after a particular word/character limit to the title
- Remove post title in catogory page
- Change Bookmark Name without Changing TITLE Tag [closed]
- reformat entry-title with two different styles
- Show page name in browser
- Trying to get more space removed from my header
- How can I structure my pseudo footer nav code with wordpress codex code?
- how to put breadcrumb under Title [closed]