How to get the current-menu-item ID?

How to get the current-menu-item ID?

Im trying to get the id of the menu item that has be class called “current-menu-item”. Not the current page id, but the nav item id. Since menu items are post-types you are able to use all the WP-Query params, even a meta query.

Why is my custom menu item not called?

As I said before we still have two problems: Let’s take care of the first one. For some reason, when our menu item relies on app:actionLayout instead of android:icon, onOptionsItemSelected will not be called for the custom menu item. This is a known problem.

How to use custom views as menu items?

By calling just a few setup methods, the framework will automatically handle three things for us. The only requirement of us is that we define a title text and icon drawable within our menu layout file, inflate this layout in onCreateOptionsMenu () and respond to clicks in onOptionsItemSelected ().

Why is onoptionsitemselected not called for custom menu items?

Let’s take care of the first one. For some reason, when our menu item relies on app:actionLayout instead of android:icon, onOptionsItemSelected will not be called for the custom menu item. This is a known problem. The solution is simply to add our own ClickListener to the root view and manually call onOptionsItemSelected.

How do I find the parent menu item?

Use the Parent property to determine the parent menu item or to access its properties. A root menu item does not have a parent menu item. To access the submenu items of the current menu item, use the ChildItems property. Is this page helpful?

Is there a parent menu in WordPress 3.0?

With the custom WordPress menus available with WordPress 3.0 there are inherent systems that allow us to identify which is the current menu item and it’s parent links. Unfortunately these aren’t very obvious and going through the source code to pick them out can be a nightmare.

How to create custom menus in WordPress themes?

The same principles can then be applied to your own menus/themes to add custom styling to active menu items or parent links. For the demonstration we will create a simple 2-tier horizontal menu. The 2nd level sub-menus are only visible when the user browses to the parent menu page.

What is the ID of the menu bar?

Each menu or command has a unique identity which is known as command ID. With the help of command id a developer can manipulate menubar. Manipulating menus in this way known as customization. Let’s see some commands and their ids.

How to get an object’s ID from its name?

In SQL Server, you can use the OBJECT_ID () function to return an object’s ID, based on its name. This can be useful when you need an object’s ID, but you only know its name.

Where does the ID for a command come from?

This ID is assigned to the user-interface object that generates the command. Typically, IDs are named for the functionality of the user-interface object they are assigned to.

How to change the title of a menu item?

I’m trying to change the title of a menu item from outside of the onOptionsItemSelected (MenuItem item) method. however I’d like to be able to modify the title of a particular menu item outside of this method. is a much better choice. I used the answer from https://stackoverflow.com/a/17496503/568197

How to change menu item text dynamically in Java?

You can do it like this, and no need to dedicate variable: It works only – after the menu created. It seems to me that you want to change the contents of menu inside a local method, and this method is called at any time, whenever an event is occurred, or in the activity UI thread.

How do you get the current list item in?

Brage’s answer is correct if I had a selection of items to work from. For this to work, you must enable item selection on the view and let the user select more than one item. SP.ListOperation.Selection will give you back a collection of list items which you can then display on a page or use as a dropdown or something.