feat: add custom excerpt length (#397)

pull/409/head^2
Seaton Jiang 2021-08-20 12:46:04 +08:00
parent 8fc242c8fe
commit b5c76af8a1
No known key found for this signature in database
GPG Key ID: 0E05070D261ACFEA
2 changed files with 10 additions and 3 deletions

View File

@ -93,11 +93,11 @@ function get_post_views($echo = 1)
} }
// 文章列表简介内容 // 文章列表简介内容
function excerpt_length($length) function custom_excerpt_length($length)
{ {
return 260; return kratos_option('g_excerpt_length', '260');
} }
add_filter('excerpt_length', 'excerpt_length'); add_filter('excerpt_length', 'custom_excerpt_length');
// 开启特色图 // 开启特色图
add_theme_support("post-thumbnails"); add_theme_support("post-thumbnails");

View File

@ -176,6 +176,13 @@ CSF::createSection($prefix, array(
'subtitle' => __('启用/禁用 Gutenberg 编辑器', 'kratos'), 'subtitle' => __('启用/禁用 Gutenberg 编辑器', 'kratos'),
'default' => false, 'default' => false,
), ),
array(
'id' => 'g_excerpt_length',
'type' => 'text',
'title' => __('文章简介缩略', 'kratos'),
'subtitle' => __('文章简介显示的字符数量', 'kratos'),
'default' => '260',
),
array( array(
'id' => 'g_renameother_fieldset', 'id' => 'g_renameother_fieldset',
'type' => 'fieldset', 'type' => 'fieldset',