(resloved) WordPress is_page() error

WordPress has this really great option of using conditional tags. They allow content (widgets, sidebars, sections of content etc.) to be used only in certain pages or posts or categories.

» More About Conditional Tags «

Recently, however, I had an occasion where it didn’t work correctly. It took a guess on my part to figure out why…

The Problem

In my page template, I had one section of text which I wanted to hide on certain pages. To do this, I used the !is_page(array(2,4,123)) conditional tag. It worked great for all of the pages but one. I tried all the different options — !is_page(array(‘2,4,’page title’)) , !is_page(array(2,4,123)) , !is_page(array(2,4,’page-slug’)) but none of them would work. It also didn’t matter where in the array the page in question happened to be (first, last or middle).

The Solution

On a guess, I changed the title “My Disclosure Policy…” to “My Disclosure Policy… ” in the edit page dashboard.

WordPress is_page() Error
WordPress is_page() Solution

While I don’t know the reason this was significant, this change solved my problem.

This also suggests that I can use HTML entities for other symbols in page titles, which is something more to think about.

 

View Comments

Leave a Reply