Widget Logic
[resolved] Getting widget to display on child pages of a child page (3 posts)

  1. suchajazzyline
    Posted 6 years ago #


    The answer may be staring me in the face, but I can't seem to figure it out. I've got a page 'entrepreneur' with a child page 'business-formation' with a number of child pages. I need my widget to display on 'business-formation' and all of its child pages. I'm currently using the following code:

    global $post; return (is_page('business-formation') || ($post->post_parent=="business-formation"));

    However, the widget only displays on the business-formation page and none of its child pages. The business-formation page is here:

    And here is a child page of business-formation:



  2. alanft
    Plugin Author

    Posted 6 years ago #

    I think the problem is that $post->post_parent can only be an integer - that is the ID of the page. You can find the numeric ID of a page in the 'edit page' screen, hover over the 'edit' link on a particular page and look at the URL of that link - it will have post=xxxx in it, that's the ID

  3. suchajazzyline
    Posted 6 years ago #

    That worked perfectly, thank you!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic