Forums

is_page Pagename and it's children (4 posts)

  1. karlevid
    Member
    Posted 1 year ago #

    I would like to get a If for page Work and all its sub pages.

    '<?php if ( is_page( 'work' ) && $post->post_parent ) { ?>'
    do this
    else ... do this.. end

  2. ucfknight10
    Member
    Posted 1 year ago #

    to do this for immediate children is quite easy, but if you have pages that are nested several layers deep, you'll need to write a function with a recursive conditional, to determine if the page is indeed a child of "work".

  3. karlevid
    Member
    Posted 1 year ago #

    hi ucfknight10. yes, i got it nested. 2 levels

    work
    - websites
    - client

  4. ucfknight10
    Member
    Posted 1 year ago #

    try this function, and see if it works for you.

    http://csstyle.pastebin.com/S1r3J1nZ

Topic Closed

This topic has been closed to new replies.

About this Topic