jdmcmillan
Member
Posted 3 years ago #
I have a small div section that shows category and date posted. I want this to be present on main pages, post pages, category pages, etc. but not on Pages. I know there are conditional tags, but they seem to only be good for showing content on Pages, not for showing something on everything EXCEPT Pages. Am I missing something? Is there something like "if Pages, then DON'T show this content"? Thanks so much for the help!
You can make a Page Template for your WordPress Pages and that will solve your problem.
Cheers,
Michael.
You can use the ! mark in PHP to evaluate a negative.
<?php if (!is_page()) { echo "not a page"; } ?>
jdmcmillan
Member
Posted 3 years ago #
ok, i don't understand how to enclose the div section with the php command mentioned by ming above.
so say i have a <div class="metal">Example Content to be seen only by pages</div>, what would the complete code look like with the ! php above?
Thanks again!
<?php if (is_Page()) { ?>
Content for pages only goes here
<?php } ?>
I don't know why you wouldn't just create a page template instead, it's much easier.
Good luck,
Michael.
jdmcmillan
Member
Posted 3 years ago #
Thanks so much for the help Michael and Ming. A page template is probably a better long-term solution, but I just needed a quick solution to exclude a small part of my content from Pages.
For future users, here is how to include a section on everything except Pages (note exclamation point):
<?php if (!is_Page()) { ?>
Content for pages only goes here
<?php } ?>