In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-13 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you how to achieve login users to display different WordPress menus, I hope you will learn something after reading this article, let's discuss it together!
If you let logged-in users and non-logged-in browsers display different menus, you can do so through the following code:
Login users display different WordPress menus. Login users display different WordPress menus
Add the following code to the current theme function template functions.php:
If (is_user_logged_in ()) {$args ['menu'] =' logged-in';} else {$args ['menu'] =' logged-out';} return $args;} add_filter ('wp_nav_menu_args',' wpc_wp_nav_menu_args')
After that, create two new menus, logged-in and logged-out, respectively, which are used to log in and the menus displayed by ordinary visitors.
If the theme has more than one menu, you can display different menus at the specified menu location with the following code:
Function wpc_wp_nav_menu_args ($args =') {if (is_user_logged_in ()) {if ('top-navigation' = = $args [' theme_location']) {/ / Change top-navigation to theme specific name$args ['menu'] =' logged-in';}} else {if ('top-navigation' = = $args [' theme_location']) {/ / Change top-navigation to theme specific name$args ['menu'] =' logged-out';}} return $args } add_filter ('wp_nav_menu_args',' wpc_wp_nav_menu_args')
You can also use the above method to make different user roles display different menu contents.
After reading this article, I believe you have a certain understanding of "how to enable login users to display different WordPress menus". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for your reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.