WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] is_subpage() function (3 posts)

  1. moody
    Member
    Posted 8 years ago #

    I'm looking for some help or guidance on the workaround for the is_page() function.
    On the Conditional Tags « WordPress Codex page there is a little line and work around that says:

    Unfortunately, there is no is_subpage() function yet. There is, however, a workaround.
    if(get_the_title($post->post_parent) != the_title(' ' , ' ',false)) { echo "This is a subpage"; }
    determines if the executing page is a subpage by checking if it isn't it's own parent (non-subpages (pages) are their own parent). In this case, it will print "This is a subpage" to the browser.

    my php is a little below marginal, but i'm sure there could be some logic that could determine if it isn't it's own parent, but it does have a parent, what's its parents ID.

    yes? no?

    help, please?

    thank you.

  2. maerk
    Member
    Posted 8 years ago #

    Does my reply on this thread help you at all?

    I'm talking specifically about the post that starts "Yeah, sorry :/ it turns out..." -- the rest of that thread is likely to be irrelevant.

  3. moody
    Member
    Posted 7 years ago #

    8 months later, I've come back to this, but yes. Your reply helped me in the since that somehow from there I found this: http://wordpress.org/support/topic/41235#post-395279

    That is exactly what I needed.

    Thank you, very much.

Topic Closed

This topic has been closed to new replies.

About this Topic