WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Only show specific nav item to members (4 posts)

  1. napalm
    Member
    Posted 4 years ago #

    Hi All,
    I wondering how i can go isolate a specific nav item as the main listing is being populated by its function.

    I would like to publish a specific nav item for members only.

    The following code if from, function t_show_pagemenu and seems to put all the nav items into a variable called $pages.

    $pages = wp_list_pages('sort_column=menu_order&title_li=&echo=0&depth=0&exclude='. $exclude);
    $pages = preg_replace('%<a ([^>]+)>%U','<a $1><span>', $pages);
    $pages = str_replace('</a>','</span></a>', $pages);
    echo $pages;

    How can i go about checking if any of the nav items are named 'monkey', so i can then set up a statement like the following:

    if (!is_user_logged_in()) {
       If a nav item = "monkey" {
       dont display it
       }
       echo $pages;
    } else {
       //poplulate as normal
       $pages = wp_list_pages('sort_column=menu_order&title_li=&echo=0&depth=0&exclude='. $exclude);
       $pages = preg_replace('%<a ([^>]+)>%U','<a $1><span>', $pages);
       $pages = str_replace('</a>','</span></a>', $pages);
       echo $pages;
    }
  2. offspring
    Member
    Posted 4 years ago #

    Maybe exclude option will help?
    http://codex.wordpress.org/wp_list_pages

  3. napalm
    Member
    Posted 4 years ago #

    Thanks Offspring.
    I love wordpress!

  4. elersong
    Member
    Posted 4 years ago #

    Hey napalm,

    do you think you can explain this modification to those of us who stink at coding?

    I'd like to have some navigation tabs hidden from non-users as well.

    Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic