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
- How to edit specific title instead of all the title calls
- Wrong site title and description in google search
- Using php to overwrite or replace title tag, while using yoast [closed]
- A check for if is parent page, if has children, if has grandchildren
- Two title tags in my header
- Auto Add Image Title,Caption,Alt Text,Description while uploading Images in WordPress
- How can I add title attributes to next and previous post link functions?
- Changing title of a page dynamically from within a plugin
- Problem in wordpress with “-“
- Prev/Next child navigation for current page?
- order by second word in title?
- How to add subscript and superscript in WordPress page titles
- add_theme_support( ‘title-tag’ ) in conflict with custom titles function
- Show content if parent page has children
- the_title filter applying to menu items
- Modify page title format (when using title-tag)
- Fill post titles from post content?
- Empty title on front page/Home
- REQUIRED: The theme must not used the tags. | REQUIRED: The theme must not call to wp_title()
- Changing “Enter title here” based on post format
- WordPress i18n-friendly preg_replace post title
- Delete Child Posts
- How to make a H1 different then the Title?
- How to set custom title of custom page template?
- 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
- Display post title on individual image attachment page
- Include category title in wp_title
- Automatically add title attribute to links in WordPress
- Get wp_title() from page ID into a variable
- How can i remove JUST the title tag from wp_head() function?
- Custom Post Type Title Placeholder [duplicate]
- Site title not showing. What can I do?
- Remove site name from tag
- posts order by title second word
- SEO meta description and title tag Yoast SEO
- List the 5 most recent child pages
- What code do you use to generate the text to go into the HTML title tag?
- How come my first blog post and my home page have the same title?
- How to intercept Post Title on Post-Save
- Where do I change the ACTUAL title tag that is set in the header.php
- Why doesn’t YoastSEO allow me to set the title/description for the home page? [closed]
- Change title tag dynamically or within plugin?
- Get title of page from URL
- Filter get_the_title to remove certain characters?
- Remove site name from title post
- Hide price & title in store thumbnail dispay? [closed]
- 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 do I set the blog name?
- How to Change Title Attribute to be different from Page title
- Add anchor text to php
- 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
- Remove post title
- Set max title length – similar to excerpt length for outside of single.php
- How to edit title on Edit post pages?
- How do I shorten the title lenghs with Elementor theme? [closed]
- Automatically add words if duplicate post titles
- Remove Title of youtube video
- WP action/filter to modify title before header output and article output?
- How to Customize “WordPress > Error” Text in Titlebar?
- How to insert icon in site title
- How to add H4 tag to the_content filter (after content)?
- How can I automatically insert the page content as the title?
- Trouble with parent and child conditional tag to show content
- HeadSpace2 double title on homepage
- Changing title & add Breadcrumbs
- Page title is showing category name as well in the google search results
- How to Change The Title in WordPress For SEO
- 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
- Why is a category/ tag name prefixed to title of every page?
- Where does Yoast SEO plugin sets the site/page title?
- How to output the title of the blogs home page
- 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
- Cannot use ‘CSS’ in post title
- How to echo all the_title() without text after last “-“
- set title attribute in wp_get_attachment_image()
- get_the_title outputs title until spacing; it does not get full length of title
- Title tags show twice
- Setting page title and keywords from PHP code
- Anyway to specify what should appear in in .php file?