• 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?

    Thanks, Gareth.

Viewing 1 replies (of 1 total)
  • Thread Starter workandtumble

    (@workandtumble)

    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.

Viewing 1 replies (of 1 total)
  • The topic ‘Adding destination post IDs to menu items via walker’ is closed to new replies.