WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Exclude page from menu only for logged in users?

[Resolved] Exclude page from menu only for logged in users?

  • 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>' ); ?>

Viewing 1 replies (of 1 total)
  • 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 } ?>
Viewing 1 replies (of 1 total)
  • The topic ‘[Resolved] Exclude page from menu only for logged in users?’ is closed to new replies.
Skip to toolbar