sna*_*pan 5 wordpress wordpress-theming wordpress-plugin
我正在尝试为我的主题添加一个特色图片,但不是为帖子或页面添加 - 我创建了一个名为Properties的自定义类型(它用于房地产经纪人),因此我如何启用特色图片,因为它没有出现在sceen选项?
希望有人能提供帮助,
$property = new Cuztom_Post_Type( 'Property', array(
'supports' => array('title', 'editor')
));
Run Code Online (Sandbox Code Playgroud)
sna*_*pan 15
$property = new Cuztom_Post_Type( 'Property', array(
'supports' => array('title', 'editor', 'thumbnail')
));
Run Code Online (Sandbox Code Playgroud)
我似乎已经解决了我自己的问题 - 见上文
您只需在主题的 function.php 文件中使用以下代码行即可为任何自定义帖子类型启用帖子缩略图支持。
add_post_type_support( 'forum', 'thumbnail' );
Run Code Online (Sandbox Code Playgroud)
注意:这里,forum
是帖子类型名称。
您可以将此代码保留在after_setup_theme
挂钩中。
这可能对某人有帮助,
add_theme_support('post-thumbnails');
add_post_type_support( 'my_product', 'thumbnail' );
function create_post_type() {
register_post_type( 'my_product',
array(
'labels' => array(
'name' => __( 'Products' ),
'singular_name' => __( 'Product' )
),
'public' => true,
'has_archive' => true
)
);
}
add_action( 'init', 'create_post_type' );
Run Code Online (Sandbox Code Playgroud)
小智 5
100% 运行此代码
add_theme_support('post-thumbnails');
add_post_type_support( 'news', 'thumbnail' );
function create_posttype() {
register_post_type( 'news',
array(
'labels' => array(
'name' => __( 'News' ),
'singular_name' => __( 'news' )
),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'news'),
'menu_icon' => 'dashicons-format-aside',
)
);
}
add_action( 'init', 'create_posttype' );
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
19553 次 |
最近记录: |