WordPress.org

Ready to get started?Download WordPress

Forums

Widget Logic
!is_page or $post->post_parent != (5 posts)

  1. Jon
    Member
    Posted 1 year ago #

    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/

  2. alanft
    Member
    Plugin Author

    Posted 1 year ago #

    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).

  3. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    I need the opposite of that

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

  4. Jon
    Member
    Posted 1 year ago #

    thank you.. changed it to:

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

  5. alanft
    Member
    Plugin Author

    Posted 1 year ago #

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

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.