WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. suchajazzyline
    Member
    Posted 4 years ago #

    Hi,

    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:
    http://64.22.105.98/~vcorpser/entrepreneur/business-formation

    And here is a child page of business-formation:
    http://64.22.105.98/~vcorpser/entrepreneur/business-formation/incorporation

    Help!
    Sarah

    http://wordpress.org/extend/plugins/widget-logic/

  2. alanft
    Member
    Plugin Author

    Posted 4 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
    Member
    Posted 4 years ago #

    That worked perfectly, thank you!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic