반응형
Wordpress - 사용자 지정 투고 유형에 피쳐 이미지 추가
테마에 특집 이미지를 추가하려고 합니다만, 투고나 페이지가 아닙니다.프로퍼티라고 하는 커스텀 타입(에스테이트 에이전트의 경우)을 작성했습니다만, 특집 이미지를 유효하게 하려면 어떻게 하면 좋을까요?
누가 도와줄 수 있으면 좋겠는데
$property = new Cuztom_Post_Type( 'Property', array(
'supports' => array('title', 'editor')
));
$property = new Cuztom_Post_Type( 'Property', array(
'supports' => array('title', 'editor', 'thumbnail')
));
나는 내 자신의 의문을 해결한 것 같다 - 위 참조
이게 도움이 될 수도 있지만
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' );
테마 기능에서 다음 줄의 코드를 사용하여 임의의 커스텀 투고 타입에 대해 지원 투고 섬네일을 유효하게 할 수 있습니다.php 파일.
add_post_type_support( 'forum', 'thumbnail' );
주의: 여기에서는forum는 포스트 타입 이름입니다.
이 코드는 에 보관할 수 있습니다.after_setup_theme갈고리를 채우다
아마 이게 도움이 될 거야
function create_post_type() {
register_post_type( 'sadaf_films',
array(
'labels' => array(
'name' => __( 'Films' ),
'singular_name' => __( 'Film' )
),
'public' => true,
'has_archive' => true,
'supports' => array( 'title', 'editor', 'custom-fields','thumbnail' ),
)
);
}
add_action( 'init', 'create_post_type' );
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' );
add_theme_support('post-thumbnails');
add_post_type_support( 'testimonial', 'thumbnail' );
function create_posttype() {
register_post_type( 'testimonial',
array(
'labels' => array(
'name' => __( 'Testimonial' ),
'singular_name' => __( 'testimonial' )
),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'testimonial'),
// add category in custom post type
'taxonomies' => array( 'category'),
)
);
}
add_action( 'init', 'create_posttype' );
커스텀 포스트 타입을 작성하기 위해 wp cli 및 scale을 사용하는 경우:
wp scaffold post-type movie ...
생성된 파일(/post-type/movie.php)에는 이미 다음 행이 있습니다.register_post_type:
supports: => ['title', 'editor' ]
여기에 '썸네일'을 추가할 수 있습니다.
supports: => ['title', 'editor', 'thumbnail' ]
언급URL : https://stackoverflow.com/questions/12543563/wordpress-adding-featured-image-to-custom-post-type
반응형
'codememo' 카테고리의 다른 글
| Wordpress: WP_post_name에 대한 검색 조건 쿼리 (0) | 2023.04.03 |
|---|---|
| Netflix Feign - 마이크로 서비스를 통해 상태 및 예외 전파 (0) | 2023.04.03 |
| 상당히 큰 JSON 파일 읽기 (0) | 2023.04.03 |
| NextJS _app.tsx 컴포넌트 및 pageProps의 TypeScript 유형을 선택합니다. (0) | 2023.04.03 |
| registerServiceWorker는 React JS에서 무엇을 합니까? (0) | 2023.04.03 |