• Resolved jdmcmillan

    (@jdmcmillan)


    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!

Viewing 5 replies - 1 through 5 (of 5 total)
  • 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"; } ?>

    Thread Starter jdmcmillan

    (@jdmcmillan)

    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.

    Thread Starter jdmcmillan

    (@jdmcmillan)

    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 } ?>

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Don’t want to show a div section on Pages’ is closed to new replies.