How can I get the post date and/or the last modified date of the target page of a menu link? I want to include this value in a data attribute.

For links to posts and pages, it should be the last modified date of the post/page. For links to post archives, it should be the date of the most recent post in that archive. For custom links, it doesnt need to have a date

I tried using $atts['data-modified'] = $item->post_modified; in a custom menu walker, but that just got the last modified date for the menu item itself.

Read more here: Get last modified date for menu link


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Wordpress related questions and answers: