How to Include and exclude pages in wordpress when someone logs in?

I have this so far

<?php 
    if(is_user_logged_in()) {
        wp_list_pages('sort_column=menu_order&depth=2&title_li=&exclude=104,101');
    }

    else {
        wp_list_pages('sort_column=menu_order&depth=2&title_li');
    }
?>

but how do I set it up so log out appears when someone is logged in?

Read More

thanks in advance.

Related posts

Leave a Reply

1 comment

  1. If you’re using version 2.7 or later, what about this?

    <? if (is_user_logged_in()): ?>
    <a href="<?=wp_logout_url()?>">Log Out</a>
    <? endif; ?>
    

    or (if you want both log in and log out links):

    <? if (is_user_logged_in()): ?>
    <a href="<?=wp_logout_url()?>">Log Out</a>
    <? else: ?>
    <a href="<?=wp_login_url()?>">Log In</a>
    <? endif; ?>
    

    Note that you can give wp_logout_url() and wp_login_url() a single string argument containing a URL to which WordPress will redirect the visitor after login/logout.

    Another Option

    If you want the default WordPress login/out link without the ability to customize the HTML and are using at least version 1.5, try wp_loginout():

    <p><?=wp_loginout()?></p>
    

    (Again, you can optionally provide a string URL redirect-to argument.)

    Hope this helps,
    Ben