Support » Plugins and Hacks » Hacks » Adding destination post IDs to menu items via walker
6 years, 1 month ago
Hi, I need help customising the output of my menu items:
Want to add the ID of the destination post as a rel attribute to each link so I can fire a bunch of jQuery a targeting the posts within the page
Have set up a custom walker that outputs my menu and rel attribute but can’t figure out how to get the ID.
$attributes .= ' rel="post-' . esc_attr( $item->attr_ID ) .'"';
Gets the id of the menu item – is it possible to get the ID of the destination post?
Another option would be to drag the slug out of the url (which we can get via $item->url – sadly my PHP know how doesn’t extend to this.