fix: 主题切换时批量开启已有 tucao 评论
This commit is contained in:
@@ -56,9 +56,19 @@ function kjweji_register_tucao() {
|
|||||||
'supports' => array('title', 'editor', 'author', 'thumbnail', 'comments'),
|
'supports' => array('title', 'editor', 'author', 'thumbnail', 'comments'),
|
||||||
'menu_position' => 25,
|
'menu_position' => 25,
|
||||||
'menu_icon' => 'dashicons-format-chat',
|
'menu_icon' => 'dashicons-format-chat',
|
||||||
|
'supports' => array('title', 'editor', 'author', 'thumbnail', 'comments'),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 主题激活时,把已存在的 tucao 文章全部开放评论
|
||||||
|
add_action('after_switch_theme', 'kjweji_open_tucao_comments');
|
||||||
|
function kjweji_open_tucao_comments() {
|
||||||
|
$posts = get_posts(array('post_type' => 'tucao', 'posts_per_page' => -1, 'post_status' => 'any'));
|
||||||
|
foreach ($posts as $post) {
|
||||||
|
wp_update_post(array('ID' => $post->ID, 'comment_status' => 'open'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ── 摘要取前 2-3 句 ───────────────────────────
|
// ── 摘要取前 2-3 句 ───────────────────────────
|
||||||
// 摘要:取文章内容的前 N 个字符(在句号处截断)
|
// 摘要:取文章内容的前 N 个字符(在句号处截断)
|
||||||
function kjweji_excerpt($max_sentences = 5, $max_chars = 300) {
|
function kjweji_excerpt($max_sentences = 5, $max_chars = 300) {
|
||||||
|
|||||||
Reference in New Issue
Block a user