开发者

Create menu items automatically when creating a page in WordPress. How to?

For Wordpress, when creating a page, a menu entry will be added to top level menu automatically. I have disabled this feature because it is not what I what.

开发者_JAVA百科What I want is, like Drupal, when creating a page, I can have a dropdown select to select which menu to add this page to and to which parent.

Which plugin can do that?

Thank you.


You can do it yourself. What you need to do is:

  1. Use add_meta_box to add a meta box to your post editor. In that meta box, build a list of available menus using results from get_registered_nav_menus() function.
  2. Add a hook to save_post action, which will create a menu item.
  3. Create a menu item by calling wp_save_nav_menu_items($menu_id, $item_data)

It is not a piece of cake, but you can do it in a couple of hours.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜