• Hi,

    This maybe a simple syntax issue or a limitation of the plugin.

    I want to exclude a widget from displaying on the front page and from displaying on the children of a certain page.

    To exclude the children I use:

    global $post; return !(is_page(25) || ($post->post_parent=="25"));

    Where “25” is the page ID of the parent.

    To exclude the front page I have been adding an OR cause “||” and the normal exclusion string “!is_front_page()” and so the widget logic reads as:

    global $post; return !(is_page(25) || ($post->post_parent=="25")); || is_front_page()

    Is it something in the syntax (which I have played with extensively) or is it a limitation???

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter mtwelve

    (@mtwelve)

    Ok so another way to exclude the children is:

    global $post; return !(in_array(25,get_post_ancestors($post)));

    As suggest in the other notes however if I try to add an OR and some logic I get the same error as before:

    Parse error: syntax error, unexpected T_BOOLEAN_OR in C:\wamp\www\oxfordhigh\wp-content\plugins\widget-logic\widget_logic.php(161) : eval()'d code on line 1

    And this is the logic I tried to use:

    global $post; return !(in_array(25,get_post_ancestors($post))); || global $post; return (in_array(236,get_post_ancestors($post)));

    Thread Starter mtwelve

    (@mtwelve)

    I have had some progress with this by using the custom is_subpage() functions mentioned in this link: https://www.mattvarone.com/wordpress/wordpress-check-page-parent

    The problem with those is as follows:

    When I try and use it reversed alongside another reversed tag; for instance. I dont want to show the menu for children of 48 on the front page or any page other than those with a parent of 48, and so my WidgetLogic looks like this: !is_subpage(48) || !is_front_page

    When I use the above code it hides the menu on children of 48 but not on the front page..?

    For added info a variation of the logic in another widget works without fault: is_subpage(48) || is_page(48) || !is_front_page()

    It seems to arise when using the reverse of the tag

    Thanks as always

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: Widget Logic] Excluding Children and the Front Page’ is closed to new replies.