【问题标题】:How to add an extra menu to wordpress admin screen如何向 wordpress 管理屏幕添加额外的菜单
【发布时间】:2013-09-21 23:18:18
【问题描述】:

我正在尝试在 wordpress 中创建一个主题,我需要在“发布”的位置下添加另一个名为投资组合的页面,该页面的作用与发布页面相同,但使用 /portfolio/post-title 的链接而不是 /blog/post-title。可能有这方面的教程,但我找不到任何特定于我正在做的事情。

【问题讨论】:

    标签: wordpress wordpress-theming portfolio


    【解决方案1】:

    是的,有成千上万的教程,如果不是数百万的话。我想你还没有尝试很多?您应该研究的功能是“自定义帖子类型”

    示例:

    function codex_custom_init() {
      $labels = array(
        'name' => 'Books',
        'singular_name' => 'Book',
        'add_new' => 'Add New',
        'add_new_item' => 'Add New Book',
        'edit_item' => 'Edit Book',
        'new_item' => 'New Book',
        'all_items' => 'All Books',
        'view_item' => 'View Book',
        'search_items' => 'Search Books',
        'not_found' =>  'No books found',
        'not_found_in_trash' => 'No books found in Trash', 
        'parent_item_colon' => '',
        'menu_name' => 'Books'
      );
    
      $args = array(
        'labels' => $labels,
        'public' => true,
        'publicly_queryable' => true,
        'show_ui' => true, 
        'show_in_menu' => true, 
        'query_var' => true,
        'rewrite' => array( 'slug' => 'book' ),
        'capability_type' => 'post',
        'has_archive' => true, 
        'hierarchical' => false,
        'menu_position' => null,
        'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' )
      ); 
    
      register_post_type( 'book', $args );
    }
    add_action( 'init', 'codex_custom_init' );
    

    资源:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-11
      相关资源
      最近更新 更多