WordPress.org

Support

Support » Plugins and Hacks » Widget Logic » !is_page or $post->post_parent !=

!is_page or $post->post_parent !=

  • this code works fine:

    global $post; return (is_page( array( 302, 730, 686 ) ) || ($post->post_parent==”686″));

    however.. for a few more of my widgets I need the opposite of that so it won’t show those on the above pages. when I change is_page to !is_page.. that works fine.. but if I change == to != for post_parent.. it messes it up.

    how would I properly write this?

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

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author alanft

    @alanft

    try taking off the quotes aroung 686. i’m not saying it’s that, but there might be something going on with PHP’s weird ‘casting’ when converting the string to an integer (which post_parent is I think).

    I need the opposite of that

    if you properly think about the logic behind this, you would want to change || to &&

    thank you.. changed it to:

    global $post; return (!is_page( array( 302, 730, 686 ) ) && ($post->post_parent!=686));

    Plugin Author alanft

    @alanft

    !! Of course! Thank you. Should have spotted that!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘!is_page or $post->post_parent !=’ is closed to new replies.
Skip to toolbar