• I am trying to exclude content on 4 pages that I have, but keep it on all the rest. I was trying to use a conditional clause, but I’m not sure how to exclude some pages. I tried the code below, but it left only the header. Does anyone have any ideas?

    <?php if ( is_page(&exclude=8,9,10,11) ) : ?>
    <?php endif; ?>

    Thanks in advance!

Viewing 7 replies - 1 through 7 (of 7 total)
  • I am not sure I understand what you are trying to do.
    Are we talking about Pages? If so, if you “exclude” the content of a Page… what the heck is shown on that Page?
    Try to describe exactly what you want to achieve, somebody might come up with the solution.

    Thread Starter x9tripboarder16

    (@x9tripboarder16)

    I have a different nav bar on 4 pages on my site. On the rest of the pages, I have the same nav bar. I want to find a code that will allow me to use the code:
    <?php if ( is_page() ) : ?>
    <?php endif; ?>
    but at the same time, exclude 4 pages.

    Currently I am doing it all by hand whereas the code reads:
    <?php if ( is_page(#) ) : ?>
    <?php endif; ?>
    And I do this for each of the pages.

    I don’t want to recreate the code for each of the pages. If you want to see, https://cs.loyolahs.org/news/

    Any help is greatly appreciated!

    Then your topic title is totally misleading!
    You do NOT want to exclude content – you want to exclude certain Pages from being listed on some particular Pages. That’s a totally different story.

    See: https://codex.www.ads-software.com/Conditional_Tags#A_PAGE_Page
    You are on the right track but you have to study the working examples in the Codex article above.
    You can approach it in two ways:
    if is_page(1,2,3,4)
    do stuff… <== your code here
    endif

    or

    is !is_page(1,2,3,4) <== which means if is NOT the listed Pages. The [!] means NOT.

    Thread Starter x9tripboarder16

    (@x9tripboarder16)

    Here is the code I am using:

    <?php if ( !is_page(8,9,10,11) ) : ?>
    <table border=”0″ cellpadding=”0″ cellspacing=”2″ width=145>
    <tr>
    <td width=”100%”>CS Home</td>
    </tr>
    <tr>
    <td width=”100%”>CS Leadership Team</td>
    </tr>
    <tr>
    <td width=”100%”>Urban Plunge</td>
    </tr>
    <tr>
    <td width=”100%”>Food & Clothing Drive</td>
    </tr>
    <tr>
    <td width=”100%”>Web Resources</td>
    </tr>
    <tr>
    <td width=”100%”>Press Room</td>
    </tr>

    </table>
    <?php endif; ?>

    But for some reason, the conditional tag only works of the first page listed. Any ideas?

    Sorry, I am a code-illiterate…
    But I think it should be something like
    <?php if ( is_page(1) || is_page(1) || is_page(3)... etc. ) { ?>

    Thread Starter x9tripboarder16

    (@x9tripboarder16)

    This is what I tried:

    <?php if ( !is_page(8) || !is_page(9) || !is_page(10) || !is_page(11) ) : ?>
    Content
    <?php endif; ?>

    <?php if ( !is_page(8) is_page(9) is_page(10) is_page(11) ) : ?>
    Content
    <?php endif; ?>

    <?php if ( !is_page(8) !is_page(9) !is_page(10) !is_page(11) ) : ?>
    Content
    <?php endif; ?>

    None worked. Any ideas?

    Thread Starter x9tripboarder16

    (@x9tripboarder16)

    Thought I would bring this up again. Does anyone have any ideas? Thanks for the help in advance!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Excluding Content’ is closed to new replies.