Forums

[resolved] Don't want to show a div section on Pages (6 posts)

  1. 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!

  2. niziol
    Member
    Posted 3 years ago #

    You can make a Page Template for your WordPress Pages and that will solve your problem.

    Cheers,
    Michael.

  3. Ming
    Member
    Posted 3 years ago #

    You can use the ! mark in PHP to evaluate a negative.

    <?php if (!is_page()) { echo "not a page"; } ?>

  4. 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!

  5. niziol
    Member
    Posted 3 years ago #

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

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

Topic Closed

This topic has been closed to new replies.

About this Topic