• Hey —

    Is there a way for a page template to access the pretty name of the parent page? I am looking for a generic way of doing this so that when a new section is added this happens automatically. This is probably doc’d all over the place, but I just can’t find it.

    Along the same lines, is there a set of ready-to-use page variables of this kind, and, if so, are they documented anywhere?

    Thanks in advance.

    thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Ready to use variables are found in the WordPress Codex, documentation site, at http://codex.wordpress.org/Template_Tags along with a lot of other information that will help you.

    Now, to your question. We have “posts” and “Pages” in WordPress. Are you talking about having the category title in the name of the post title when it appears on a post? Or Page?

    For a post, if it is in the category of Fruits, say, it might look like this:

    Fruits >> I Once Ate an Apple
    There once was an apple that I ate………

    Like that?

    Thread Starter brooklynwebguy

    (@brooklynwebguy)

    Thanks Lorelle —

    I saw that page and then forgot it. That’s helpful but, near as I can tell, doesn’t have what I seek.

    But as usual, digging a little deeper into the forum here yielded the answer. Here it is for anyone who came to this thread seeking the same thing. Seems to work, but let me know if I’m doing something stupid.

    <?php
    if( 0 != $post->post_parent ) {
    $post_title = $wpdb->get_var(“SELECT post_title from $wpdb->posts WHERE ID = $post->post_parent”);
    }

    echo $post_title; ?>

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Accessing Title of Parent Page’ is closed to new replies.