Support » Fixing WordPress » Only show specific nav item to members

  • Resolved napalm

    (@napalm)


    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;
    }
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Only show specific nav item to members’ is closed to new replies.