There is no need to add any code for this. You can use the Screen Options
on the menu admin end to achieve this. Please check the instructions below.
-
Login to the admin end of your wordpress site and navigate to
Appearance
=>Menus
section. -
Click the down arrow against the menu item you need to have a different class for.
-
Then click on the
Screen Options
link on the top right section of your screen. -
Check/click the
CSS Classes
option. Once checked, it will show an additional fieldCSS Classes (optional)
below the menu item you had expanded earlier. -
Now provide any custom class in the field and add the respective css code in your theme’s css file.
Note:
- These steps are based on WordPress 3.8 version which may slightly vary if you are using a different version.
Related Posts:
- Passing a parameter to filter and action functions
- Get a list of all registered actions
- Schedule WordPress Auto-Updates to only run during business hours
- Preventing a plugin from updating
- How To Determine If A Filter Is Called In A Sidebar/Widget Context?
- Customizing subject in comment notification e-mails
- WP showing “warning: call_user_func_array()”, What to do?
- Filter Hook on plugin update
- WordPress Hook that will run when media file deleted
- Disallow a user to post in certain categories
- Generic plugin (de)activation hook?
- Which hook should be used to validate custom form fields on the login form?
- Hook (upgrader_process_complete) running moment
- Adding a form at the end of the content
- How can I add a custom meta value on file upload?
- Adding dynamic section to WordPress
- How can I filter blog name?
- why does the add_action(‘the_content’) overwrite my page
- Fatal error: Class not found in
- woocommerce product attributes
- How to filter content post only on save
- Filter or action hook to insert content on admin pages before tag
- Showing Notifications While Activating Plugin
- plugin_action_links_{$plugin_file} hook not in the main plugin file
- Woocommerce Shipping module available only for type of products [closed]
- WordPress Plugin Boilerplate – add_action hook in static “activate” function
- Put code into body tags near top, using a plugin
- merging an array to an existing array using add_filter
- template_redirect not being called when using ajax
- Hook before & after plugin / core update
- publish_post plugin hook doesn’t always pass $post->post_content
- Plugin custom Action Hook not working
- get_plugins() doesn’t work after plugins_loaded
- Hook to generate a dynamic sitemap with “All in One SEO Pack” Plugin
- add_action in functions.php, do_action in plugin?
- How to correctly detect accessing wp-content/uploads?
- add action for displaying posts using a shortcode
- Randomize attachment IDs
- Are there hooks for WordPress updates?
- Pass info from functions.php to plugin
- Plugin activation hook in an abstract class
- Remove rewrite rules generated by plugin during deactivation
- Change permalink structure hidden button edit
- WordPress filter that hook after each action/filter hook
- When to use action hooks and plugins
- Is there an earlier hook than login_head or login_enqueue_scripts?
- Gravity Forms plugin: How to use “gform_editor_js” action hook? [closed]
- Using a post-signup hook to get user details
- Map a custom id to wordpress post id
- Trigger Elementor Popup via code [closed]
- Calling plugin function inside custom plugin for onclick event
- get current date + 90 days and checking every day
- Calculate price and display on woocommerce product single page under price (simple price, variable price) [closed]
- Filtering WooCommerce Orders by Category
- How to get post ID with hooks publish_post, new_to_publish, etc
- Add sub menu page in your plugin
- how to change automatic placing of social plugins below content?
- Deactivate JS Script in Plugin Shortcode
- Plugin Development – Functions or Hooks?
- Are there action hooks for comments?
- Adding Plugin Assets to Header
- What are admin hooks
- How do I add $_SESSION[”] to my wordpress page?
- WooCommerce: after install hook
- How to use filter to disable adding a product to wishlist?
- WordPress: Add custom add_filter for custom functions
- Function added to hook “new_to_publish” not executing – custom plugin
- Comment Approve – Add custom function when comment is approved
- Hook on creating a menu entry?
- Prevent plug-in scripts on a specific template?
- using wp_footer hook in a plugin
- Hook for plugin to insert into entry-meta
- Use a hook or filter, or overwrite this Gamipress function?
- Hook from plugin doesn’t fire up from external PHP script
- WordPress Custom Hook with Class method
- How to remove a hook written with $this?
- Is there a hook similar to “save_post” which only fires AFTER the post is completely published?
- update_option_{$option} not working (do function after options are saved)
- add a hook of Woocommerce to a plugin but it only shows and doesn’t function properly
- Randomize post (and page) IDs on generation
- save_post hook partly firing in update post
- ACF Fields are not showing up on Homepage
- Show post object of any page in frontend
- When/where would want to attach other classes to the base class in a WordPress plugin?
- Use action, filter, or hook to append HTML to WordPress plugin function
- Passing function into add_action always returns the first argument
- Hook to display element as product on category page
- Is it possible to disable a theme programmatically?
- plugin not hooking to my custom hook
- wp_login_form() ignoring login_form action hook
- Creating Custom Hook for my plugin
- Modify a plugin’s content
- Manually return false for function_exists
- Plugin hook breaks new WP 4.0 media library grid view?
- Plugin Hook: Get posts
- Variable scope in plugin outside loop [closed]
- Checking url from plugin [duplicate]
- User register hook can’t access form request
- WordPress Hooks : Where to place callbacks that repetitively yield the same effect?
- Neither update_option nor delete_option fires in deactivation hook