WordPress.org

Ready to get started?Download WordPress

Forums

Widget Logic
[resolved] Conditional Statement for Multiple Page Templates? (6 posts)

  1. Mike
    Member
    Posted 3 years ago #

    In Widget-Logic, I can use a conditional statement for a particular widget to display if it is not a given page template. Example:
    !is_page_template('pagetemplate-this.php')

    However, it doesn't seem to work if I specify multiple templates. Example:
    !is_page_template( array('pagetemplate-this.php','pagetemplate-that.php','pagetemplate-other.php'))

    What am I doing wrong?

    thanks,
    Mike

  2. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    is_page_template() does not take an array as argument.

    try:

    !is_page_template('pagetemplate-this.php') && !is_page_template('pagetemplate-that.php') && !is_page_template('pagetemplate-other.php')

    http://codex.wordpress.org/Function_Reference/is_page_template

  3. Mike
    Member
    Posted 3 years ago #

    Awesome, that worked! I had read somewhere to put double-pipe charachers *||* where you have the ampersands. That did not work, but the ampersands did! THANK YOU!

  4. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    check up general on BOOLEAN ALGEBRA http://en.wikipedia.org/wiki/Boolean_algebra_(logic)

    || stands for OR and you can't by logic not combine negated results this way.

    && stands for AND which in your case makes sure that all three nagated conditions have to be met at the same time.

  5. Mike
    Member
    Posted 3 years ago #

    Ah, makes sense. Thanks again!

  6. Mike
    Member
    Posted 3 years ago #

    I guess I should have looked in the "Other Notes". In case it helps someone else, good explanations here: http://wordpress.org/extend/plugins/widget-logic/other_notes/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic