diff --git a/functions.php b/functions.php index fcf6fca..b1862f4 100644 --- a/functions.php +++ b/functions.php @@ -196,3 +196,23 @@ function kjweji_setup_pages() { } flush_rewrite_rules(); } + +// 自定义文章类型:拾影 +add_action('init', 'kjweji_register_photo'); +function kjweji_register_photo() { + register_post_type('photo', array( + 'labels' => array( + 'name' => '拾影', + 'singular_name' => '拾影', + 'add_new' => '发拾影', + 'add_new_item' => '发新拾影', + 'edit_item' => '编辑拾影', + ), + 'public' => true, + 'has_archive' => false, + 'show_in_rest' => true, + 'supports' => array('title', 'editor', 'author', 'thumbnail'), + 'menu_position' => 26, + 'menu_icon' => 'dashicons-format-gallery', + )); +} diff --git a/page-photos.php b/page-photos.php index bd4ac13..ab2e55c 100644 --- a/page-photos.php +++ b/page-photos.php @@ -7,7 +7,7 @@ get_header(); // 获取所有带特色图片的文章(普通文章 + 可选 tucao) $photo_query = new WP_Query(array( - 'post_type' => 'post', + 'post_type' => 'photo', 'posts_per_page' => -1, 'meta_key' => '_thumbnail_id', )); diff --git a/single-photo.php b/single-photo.php new file mode 100644 index 0000000..b2344fb --- /dev/null +++ b/single-photo.php @@ -0,0 +1,46 @@ + + + + + +
+ + +