• Resolved jmadz1

    (@jmadz1)


    Hello again guys.
    Ok this is a strange question, because you wouldn’t normally want this, but here goes.

    I’m looking for some code that is basically an if function:
    Page has parent? YES: Get parent title. NO: Get current page title.

    It sounds simple to me, but I’m having trouble intergrating the two.

    Here’s what I’ve got so far. This is to call just the parent title (so it only works if I’m on a sub page):

    <?php
    $parent_title = get_the_title($post->post_parent);
    echo $parent_title;
    ?>

    Anyone know how to create the whole function?

    Thanks in advance. Also, my site if anyone’s interested: http://www.pullupbarsx.com

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Get parent title, or if no parent, get page title?!?!’ is closed to new replies.