is_page not working on sidebar – how do I add a new template?
-
looking to have a dynamic sidebar, but sidebar template doesn’t seem to realize what page it’s being displayed on. My code is correct and I’ve tried multiple variances:
<?php if (is_page('72')) { echo "page id 72"; } ?>
<?php if (is_page('content')) { echo "page named content"; } ?>
the two examples above do not parse at all; i.e. echoed text does not appear.
<?php if (is_page()) { echo "any page at all"; } else { echo "this is NOT a page"; } ?>
the above example returns “this is not a page” on all pages, as well as home. All this code is being tested in the sidebar template, in the same wordpress theme I am using.
I fear this may be an unfixable bug of some sort. What I may do instead to combat it is create a new template for every sidebar variance I require (i.e. multiple sidebar templates), then call specific versions on a per-page basis. Can anyone instruct me on how to do this?
thank you.
- The topic ‘is_page not working on sidebar – how do I add a new template?’ is closed to new replies.