WordPress.org

Ready to get started?Download WordPress

Forums

Adding destination post IDs to menu items via walker (2 posts)

  1. workandtumble
    Member
    Posted 3 years 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?

    Thanks, Gareth.

  2. workandtumble
    Member
    Posted 3 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags