【问题标题】:How to show post formats in custom post types?如何在自定义帖子类型中显示帖子格式?
【发布时间】:2015-06-03 13:06:04
【问题描述】:

我在 wordpress 中创建自定义帖子类型。但我也想显示帖子格式报价和图像。我在哪里选择帖子格式报价或图像。这是我的自定义帖子类型代码!

function Quotes_sky() {
    $labels = array(
        'name'               => _x( 'Quotes', 'post type general name', 'your-plugin-textdomain' ),
        'singular_name'      => _x( 'Quote', 'post type singular name', 'your-plugin-textdomain' ),
        'menu_name'          => _x( 'Quotes', 'admin menu', 'your-plugin-textdomain' ),
        'name_admin_bar'     => _x( 'Quote', 'add new on admin bar', 'your-plugin-textdomain' ),
        'add_new'            => _x( 'Add New', 'Quote', 'your-plugin-textdomain' ),
        'add_new_item'       => __( 'Add New Quote', 'your-plugin-textdomain' ),
        'new_item'           => __( 'New Quote', 'your-plugin-textdomain' ),
        'edit_item'          => __( 'Edit Quote', 'your-plugin-textdomain' ),
        'view_item'          => __( 'View Quote', 'your-plugin-textdomain' ),
        'all_items'          => __( 'All Quotes', 'your-plugin-textdomain' ),
        'search_items'       => __( 'Search Quotes', 'your-plugin-textdomain' ),
        'parent_item_colon'  => __( 'Parent Quotes:', 'your-plugin-textdomain' ),
        'not_found'          => __( 'No Quotes found.', 'your-plugin-textdomain' ),
        'not_found_in_trash' => __( 'No Quotes found in Trash.', 'your-plugin-textdomain' )
    );

    $args = array(
        'labels'             => $labels,
        'public'             => true,
        'publicly_queryable' => true,
        'show_ui'            => true,
        'show_in_menu'       => true,
        'query_var'          => true,
        'rewrite'            => array( 'slug' => 'Quotes' ),
        'capability_type'    => 'post',
        'has_archive'        => true,
        'hierarchical'       => false,
        'menu_position'      => 5,
        'menu_icon'          => 'dashicons-editor-quote', 
        'supports'           => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' ) ,
        'taxonomies'         => array ( 'category', 'post_tag' )

        );

    register_post_type( 'Quotes Sky', $args );
}

这是屏幕短。希望这有助于理解我的问题

【问题讨论】:

    标签: php wordpress custom-post-type


    【解决方案1】:

    'post-formats' 需要添加 'support'..可能是 halpful

    'supports'           => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments', 'post-formats')
    

    【讨论】:

      猜你喜欢
      • 2022-07-20
      • 1970-01-01
      • 2016-11-29
      • 1970-01-01
      • 2020-05-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-29
      相关资源
      最近更新 更多