wordpress show the parent page title with fallback to title

in wordpress either show the parent page title, or if it does not have a parent then show the page title.


if($post->post_parent) {
   $parent_title = get_the_title($post->post_parent);
   echo $parent_title;
else {
   echo get_the_title();

Page Views

This page has been viewed 83 times.

Search Code
Search Code by entering your search text above.

This is my test area for webdev. I keep a collection of code snippits here, mostly for my reference. Also if i find a good site, i usually add it here.


Random Quote
I believe that in order to better your knowledge base, it takes a lot of failing in order to succeed. I don't consider anything a failure as long as you get back up and you learn from your own mistakes.