Link to home
Create AccountLog in
Avatar of cptnem0
cptnem0Flag 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

Avatar of James Rodgers
James Rodgers
Flag of Canada image

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
Avatar of cptnem0

ASKER

thanks jester,

ok, i see i did refer to it as post once, oops.
Avatar of 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
ASKER CERTIFIED SOLUTION
Avatar of James Rodgers
James Rodgers
Flag of Canada image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer