简体   繁体   English

在安装主题时在wordpress中添加自定义菜单项

[英]Adding a custom menu item ine wordpress when theme is installed

I have a wordpress theme that runs a 'bootstrap' script when the theme is activate. 我有一个wordpress主题,当该主题被激活时会运行“ bootstrap”脚本。 This generates some pages, content, media and menus. 这会生成一些页面,内容,媒体和菜单。 The items in these menus are currently created based on the pages generated however I also need to add one custom menu item to one of the menus at the same time. 这些菜单中的项目当前是基于生成的页面创建的,但是我还需要同时向一个菜单中添加一个自定义菜单项。

I have managed to get the 'nav_menu_item' post inserted with the following array of data: 我设法将'nav_menu_item'帖子插入以下数据数组:

array(
    'post_title' => 'Staff',
    'post_content' => '',
    'post_status' => 'publish',
    'post_author' => 1,
    'post_type'=>'nav_menu_item',
    'menus'=>array('0')
);

This creates the 'post' I now need to inject the postmeta information to create the menu item itself. 这将创建“ post”,我现在需要注入postmeta信息来创建菜单项本身。 I can't work out which wordpress function would be used to do this. 我无法确定将使用哪个wordpress函数来执行此操作。

I have the inserted ID for the 'post' available as I believe this is required in the postmeta. 我已经为“帖子”插入了ID,因为我认为这在postmeta中是必需的。

Any help much appreciated, Thanks 任何帮助,不胜感激,谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM