Avatar of cptnem0
cptnem0
Flag for United States of America asked on

Show parent title when in child and when in parent

Im trying to figure out how to show the title of the parent post wither on the parent or child of parent.

Ie: Page parent About > child Contact > child 2 "Staff"

The nav will say:

About
 - Contact
 - Staff

No matter if on "about" or "contact" or "Staff"

I have:

post_parent) {
$parent_title = get_the_title($post_parent);
echo $parent_title;


Works great when in child, but does not show when in parent.

Any suggestions?
post_parent) {
$parent_title = get_the_title($post_parent);
echo $parent_title;

Open in new window

WordPressPHP

Avatar of undefined
Last Comment
James Rodgers

8/22/2022 - Mon
James Rodgers

1) you are confusing pages and posts, what you are describing is a pages hierarchy - posts do not have children or parents
2) take a look at wp-pagesnav plugin, it will do what you are looking for, might need to tweak it a bit
cptnem0

ASKER
thanks jester,

ok, i see i did refer to it as post once, oops.
cptnem0

ASKER
http://wordpress.org/extend/plugins/wp-pagesnav/

pagesNav looks promising and I might use in the future, however, I am really looking for the correct php for the statement.

Something like.. if page has parent echo parent else echo page title
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
James Rodgers

ASKER CERTIFIED SOLUTION
James Rodgers

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.