Support » Plugins » Excluding multiple template pages in Widget Logic sidebar plugin

  • Hi:

    I successfully excluded one page_template using Widget Logic, so I tried extending it to multiple pages.

    I’m using this string in the widget logic text box:

    !is_page_template('proj-ed.php', 'proj-civil.php', 'proj-comm.php', 'proj-senior.php')

    to try to exclude multiple pages from referencing a sidebar widget. Is there anything wrong with this formulation? Are the spaces causing it to not work? FWIW, proj-ed.php is the template that still works. all the other do not.

    I’m also using HTML Javascript adder plugin, although that does not matter when I’m just excluding one template-which works.

Viewing 4 replies - 1 through 4 (of 4 total)
  • well i looked on the conditional tags page in the codex, at http://codex.wordpress.org/Conditional_Tags#Is_a_Page_Template , and the only example given is to test a single given filename.

    so the best way to check against a list of templates would be to get the template and do something like:

    in_array($template_name, array(‘proj-ed.php’, ‘proj-civil.php’,…))

    Now there is a function get_page_template(), but digging around that seems to return the whole PATH, not just the filename. so you could supply the array of paths, or use PHP’s basename function:

    in_array(basename(get_page_template()), array(‘proj-ed.php’, ‘proj-civil.php’,…))

    Thread Starter Joe VanDerBos

    (@joevdb)

    Thanks for the tip… I’ll see what I can do.

    Thread Starter Joe VanDerBos

    (@joevdb)

    I tried to simplify this in Widget logic, by including the string:
    !is_page_template('proj-ed.php') || !is_page_template('proj-civil.php') || !is_page_template('proj-comm.php') || !is_page_template('proj-senior.php')

    It didn’t work. It worked when I reduced the string to just
    !is_page_template('proj-ed.php')

    I checked the Use ‘wp_reset_query’ fix box at the bottom of the widget page. On or off did not work. Is there something wrong with this syntax?

    Thread Starter Joe VanDerBos

    (@joevdb)

    I gave up and just set up another page_template so I could create a positive test for one page, not an exclusion for 4.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Excluding multiple template pages in Widget Logic sidebar plugin’ is closed to new replies.