WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Exclude page from menu only for logged in users? (2 posts)

  1. sharris203
    Member
    Posted 4 years ago #

    Hey guys i need some help. I want to exclude a page from the nav menu (wp_list_pages) but only while they are logged in .

    Starting code:

    <?php wp_list_pages( 'title_li=&depth=&link_before=<span>&link_after=</span>' ); ?>

    I think this is close to what I need:

    <?php wp_list_pages( 'title_li=&depth=<?php if ( is_user_logged_in() ) { &exclude=6 } ?>&link_before=<span>&link_after=</span>' ); ?>
  2. sharris203
    Member
    Posted 4 years ago #

    Solved it like this:

    <?php if ( is_user_logged_in() ) { ?>
        <?php wp_list_pages( 'title_li=&depth=&exclude=6&link_before=<span>&link_after=</span>' ); ?>
    <?php } else { ?>
        <?php wp_list_pages( 'title_li=&depth=&link_before=<span>&link_after=</span>' ); ?>
    <?php } ?>

Topic Closed

This topic has been closed to new replies.

About this Topic