WordPress.org

Ready to get started?Download WordPress

Forums

Excluding Content (8 posts)

  1. x9tripboarder16
    Member
    Posted 8 years ago #

    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!

  2. moshu
    Member
    Posted 8 years ago #

    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.

  3. x9tripboarder16
    Member
    Posted 8 years ago #

    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, http://cs.loyolahs.org/news/

    Any help is greatly appreciated!

  4. moshu
    Member
    Posted 8 years ago #

    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: http://codex.wordpress.org/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.

  5. x9tripboarder16
    Member
    Posted 8 years ago #

    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?

  6. moshu
    Member
    Posted 8 years ago #

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

  7. x9tripboarder16
    Member
    Posted 8 years ago #

    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?

  8. x9tripboarder16
    Member
    Posted 8 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags