WordPress.org

Support

Support » Themes and Templates » if(!is_page())

if(!is_page())

  • I’ve got a few bits of template functionality in PHP files that I call in using include (TEMPLATEPATH . ‘/path/to/file’); however, I want to prevent those bits of code from being included on certain pages.

    I’ve added the below code to my template, and that prevents the code from being included on the specified page.

    if (!is_page(1)) { include (TEMPLATEPATH . 'path/to/file'); }

    However, if I try to exclude multiple pages, or a combination of pages and categories, it stops the code from working completely, using the below code:

    if (!is_page(1) || !is_page(2)) { include (TEMPLATEPATH . 'path/to/file'); }

    if (!is_page(1) || !is_category(1)) { include (TEMPLATEPATH . 'path/to/file'); }

    Is there a correct/better way of doing this?

    Cheers.

Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘if(!is_page())’ is closed to new replies.