How to get Menu Item Id by post id [WordPress]

I need to get menu item id that related to the post.

For example: I have this code:

Read More
<li id="menu-item-84" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-home menu-item-84">
<a href="http://mydominan.com/">Main Page</a>
</li>

I can get post ID from url like this :

$postid = url_to_postid( $url );

Now I need to get menu-item-id that attatched to that post. Is it posible to do that?

PS: I’m working now with ajax + history API and I don’t want to deal with history.states, so I decided to put in ajax respond array with post_title, post_content and menu item id to define active menu.

Related posts

Leave a Reply