WordPress-如何获取当前菜单中所有页面的ID


WordPress - How to get IDs for all pages in the current menu?

我正在构建一个单页滚动wordpress主题,我希望能够创建一个简单的循环,基本上可以获取当前菜单中的页面id,然后吐出内容。

我已经知道如何在给定id的情况下为页面吐出内容,但我不知道从当前菜单中获取所有id的正确方法是什么。

有什么建议吗?

想好了:

$menuItems = wp_get_nav_menu_items('main-menu');
foreach($menuItems as $page) {
    $post = get_post($page->object_id);
    $content = apply_filters('the_content', $post->post_content);
    echo $content;
}