Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WordPress: get post_parent title

I've created a custom sidebar that grabs the post parent's pages:

query_posts("post_type=page&post_parent=6"); 

I'd like to grab the title of the post_parent (i.e. "About"). the_title won't work because it's the title of the child pages.

How can I output the post_parent title?

like image 610
Ryan Avatar asked Mar 04 '11 19:03

Ryan


1 Answers

echo get_the_title( $post->post_parent );

or

echo get_the_title( X );

Where X is any valid post/page ID.

No need to get a complete post object just for one property.

like image 124
t31os Avatar answered Sep 21 '22 09:09

t31os