v1.4 — Photo 详情页画廊
- 灯箱画廊:点击图片全屏查看,多图左右切换 - 单图隐藏左右箭头,边界隐藏对应方向键 - 画廊顶部显示'标题 · 作者' - 文章导航保留在灯箱底部 - 图片去重(特色图与正文图片不重复) - 纯黑背景 - 已知限制:画廊内切换文章后灯箱不保持(AJAX 模式未稳定)
This commit is contained in:
+16
-1
@@ -210,10 +210,25 @@ function kjweji_register_photo() {
|
||||
),
|
||||
'public' => true,
|
||||
'has_archive' => false,
|
||||
'rewrite' => array('slug' => 'photo'),
|
||||
'rewrite' => array('slug' => 'photo/%post_id%'),
|
||||
'show_in_rest' => true,
|
||||
'supports' => array('title', 'editor', 'author', 'thumbnail'),
|
||||
'menu_position' => 26,
|
||||
'menu_icon' => 'dashicons-format-gallery',
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
|
||||
add_filter('post_type_link', function($link, $post) {
|
||||
if ($post->post_type === 'photo' && $post->post_status === 'publish') {
|
||||
return home_url(user_trailingslashit('/photo/' . $post->ID . '/' . $post->post_name));
|
||||
}
|
||||
return $link;
|
||||
}, 10, 2);
|
||||
|
||||
// 匹配 /photo/123/slug/ 格式
|
||||
add_action('init', function() {
|
||||
add_rewrite_rule('^photo/([0-9]+)/([^/]+)/?$', 'index.php?post_type=photo&p=$matches[1]', 'top');
|
||||
add_rewrite_rule('^photo/([0-9]+)/?$', 'index.php?post_type=photo&p=$matches[1]', 'top');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user