我希望为“staff”类别创建一组静态页面,然后在仪表板中为它们提供一个单独的菜单选项,类似于已经存在的“pages”选项。我想知道的是,是否有一个内置的wordpress函数可以加速这个开发。如果你对从哪里开始搜索有什么建议,那就太好了,因为我当前的搜索被无数关于如何添加新页面或如何复制页面的教程所阻碍,而不是复制“页面”菜单。
对这篇文章内容广泛、含糊不清表示歉意。我是wordpress的新手,我仍然在吸收这个庞大的知识库。
我希望为“staff”类别创建一组静态页面,然后在仪表板中为它们提供一个单独的菜单选项,类似于已经存在的“pages”选项。我想知道的是,是否有一个内置的wordpress函数可以加速这个开发。如果你对从哪里开始搜索有什么建议,那就太好了,因为我当前的搜索被无数关于如何添加新页面或如何复制页面的教程所阻碍,而不是复制“页面”菜单。
对这篇文章内容广泛、含糊不清表示歉意。我是wordpress的新手,我仍然在吸收这个庞大的知识库。
没有你想象的那么模糊。这是一种非常常用的方法。我建议您关注的是创建custom post type. 这将为您提供管理菜单项、类别(或任何您喜欢的分类结构)和许多其他功能。
CPT的注册和修改非常简单。它们非常适合存储数据,如商店中的产品、旅游网站的目的地等。
可以找到寄存器函数(register\\u post\\u type())的完整文档here
您需要注册自己的自定义帖子类型。我建议您将此添加到函数文件中,并根据需要进行调整,而不是试图弄清楚如何正确执行此操作(如其他答案所述):
function custom_post_type() {
// Set UI labels for Custom Post Type
$labels = array(
\'name\' => _x( \'Staff\', \'Post Type General Name\' ),
\'singular_name\' => _x( \'Staff\', \'Post Type Singular Name\' ),
\'menu_name\' => __( \'Staff\' ),
\'parent_item_colon\' => __( \'Parent Staff\' ),
\'all_items\' => __( \'All Staff\' ),
\'view_item\' => __( \'View Staff\' ),
\'add_new_item\' => __( \'Add New Staff\' ),
\'add_new\' => __( \'Add New\' ),
\'edit_item\' => __( \'Edit Staff\' ),
\'update_item\' => __( \'Update Staff\' ),
\'search_items\' => __( \'Search Staff\' ),
\'not_found\' => __( \'Not Found\' ),
\'not_found_in_trash\' => __( \'Not found in Trash\' ),
);
$args = array(
\'label\' => __( \'staff\' ),
\'description\' => __( \'Staff List\'),
\'labels\' => $labels,
// Features this CPT supports in Post Editor
\'supports\' => array( \'title\', \'author\', \'revisions\', \'author\', \'thumbnail\', \'excerpt\', \'revisions\', \'page-attributes\'),
// You can associate this CPT with a taxonomy or custom taxonomy.
\'taxonomies\' => array( \'category\' ),
/* A hierarchical CPT is like Pages and can have
* Parent and child items. A non-hierarchical CPT
* is like Posts.
*/
\'hierarchical\' => false,
\'public\' => true,
\'show_ui\' => true,
\'menu_icon\' => \'dashicons-businessman\',
\'show_in_menu\' => true,
\'show_in_nav_menus\' => true,
\'show_in_admin_bar\' => true,
\'menu_position\' => 5,
\'can_export\' => true,
\'has_archive\' => true,
\'exclude_from_search\' => false,
\'publicly_queryable\' => true,
\'capability_type\' => \'page\',
);
// Registering your Custom Post Type
register_post_type( \'staff\', $args );
}
add_action( \'init\', \'custom_post_type\', 0 );
然后你可以single-staff.php
和archive-staff.php
显示员工结果。分类为category
如上所述,它将设置类别,以便您可以使用该类别创建菜单项。在wp admin中有一个很好的创建和编辑菜单项的插件。请在此处查看:
https://wordpress.org/plugins/admin-menu-editor/
您可以使用它创建自定义菜单项。您可能还需要创建一个自定义的帖子类型或页面,其中包含要加载新菜单链接的文本或内容。对于在wordpress中生成内容的任何东西,都可以使用插件,这是一种很好的做法。将其直接编码为主题。
希望这有帮助!
我正在尝试添加wp-link-pages 功能到我的帖子中,我将图片拆分为多个页面。我已经有了next和prev按钮,其功能是用javascript编写的。如果我想从图1跳到图14,我觉得很难。所以我不知道如何实现这个wordpress,因为我是一个傻瓜。下面是我用来将帖子图像拆分为多个页面的代码。<?php global $post; if (has_post_thumbnail( $