Show or Hide Menu Items

A special menu filtering feature has been added to the theme allowing you to show or hide links in your main menu from users based on "conditional" functions. To use the filtering you must add a special class name to your link which will be the condition used to do the test. If the test returns "true" the link will be shown, "false" it will be removed.

The basic usage consists of the term "function-" followed by a WordPress conditional function where the "_" characters are replaced by "-". For example, if you wanted to hide a link from public users you would enter the class "function-is-user-logged-in" and it would only show the link for users that are logged in. This makes use of the WordPress function "is_user_logged_in()" but is formatted so the filtering feature can read it.

To test the opposite, and only show links to logged out (public) users, add “-” to the beginning of the class, "-function-is-user-logged-in", and only logged out users will see the link.

Other examples include:

  • function-is-home or function-is-front-page to only show a link on the home page
  • function-is-category to only show a link on category pages
  • function-is-singluar to only show a link on posts
  • function-is-sticky to only show a link on sticky posts
  • function-is-page to only show a link on pages
  • function-is-search to only show a link on search results, etc…

Almost any function which returns true/false can be used for this feature. There are a number of conditional functions built into WordPress already. You can see a full list of these conditional functions here: http://codex.wordpress.org/Conditional_Tags

Print Friendly, PDF & Email