WordPress.org

Support

Support » Plugins and Hacks » [Resolved] [Plugin: Widget Logic] Only for parent and child pages?

[Resolved] [Plugin: Widget Logic] Only for parent and child pages?

Viewing 4 replies - 1 through 4 (of 4 total)
  • isle2isle
    Member

    @isle2isle

    I’m looking for an answer to this too.

    Plugin Author alanft
    Member

    @alanft

    i googled this

    http://www.wpgeek.com/tutorials/how-to-check-if-wordpress-page-have-subpages-or-childrens/

    which suggests you could do this for when a page has children

    global $post; return (count(get_pages('child_of='.$post->id))>0);

    this for checking the page has a parent

    global $post; return($post->post_parent != 0);

    and then combine when either is true with

    global $post; return (count(get_pages('child_of='.$post->id))>0) || ($post->post_parent != 0);

    i’d be interested to know if that works

    isle2isle
    Member

    @isle2isle

    That didn’t work, but I finally got this to do it.
    (Replace ‘123’ in the line below with the parent page ID number)

    global $post; return (is_page(‘123’) || ($post->post_parent==”123″));

    Plugin Author alanft
    Member

    @alanft

    great, glad you’re sorted.

    that’s the solution for a specific page or the children of a specific page.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Resolved] [Plugin: Widget Logic] Only for parent and child pages?’ is closed to new replies.