代码放在func.php里,然后在后台编辑或新建文章
参照上图右下角,有一个文章有效期,往死里戳文章源自小武站https://1z345.cn/小武站-https://bbs.50-0.cn/791.html
保存或更新后,前台对应文章就会有一个倒计时。时间一到,自动进入回收站。文章源自小武站https://1z345.cn/小武站-https://bbs.50-0.cn/791.html
//文章有效期
CSF::createMetabox('post_validity_options', array(
'title' => '文章有效期',
'post_type' => ['post', 'page', 'forum_post'],
'context' => 'side',
'data_type' => 'unserialize',
));
CSF::createSection('post_validity_options', array(
'fields' => array(
array(
'id' => 'post_validity_time',
'type' => 'date',
'desc' => '设置内容的有效期,请确保格式正确,例如:<code>2020-10-10 23:59:59</code></br>到期后将会自动删除此此内容',
'settings' => array(
'dateFormat' => 'yy-mm-dd 23:59:59',
'changeMonth' => true,
'changeYear' => true,
),
),
),
));
add_filter('the_content', 'zib_c_the_content_asdfsdf');
function zib_c_the_content_asdfsdf($content)
{
$post_id = get_the_ID();
$time = get_post_meta($post_id, 'post_validity_time', true);
if ($time) {
$end_time = date("m/d/Y H:i:s", strtotime($time));
$over = '<script type="text/javascript">window.location.reload()</script>';
$content = '<div class="badg c-red block mb20"><i class="fa fa-clock-o mr10"></i>当前内容将于<span class="" data-over-text="' . esc_attr($over) . '" data-countdown="' . $end_time . '"></span>后失效</div>' . $content;
}
return $content;
}
add_action('template_redirect', 'zib_c_template_redirect_sadfasdfkjlaksdf');
function zib_c_template_redirect_sadfasdfkjlaksdf()
{
if (is_single()) {
$post_id = get_the_ID();
$time = get_post_meta($post_id, 'post_validity_time', true);
if ($time && strtotime($time) < strtotime(current_time('Y-m-d H:i:s'))) {
//执行删除文章
wp_trash_post($post_id);
wp_safe_redirect(home_url());
exit;
}
}
}
文章源自小武站https://1z345.cn/小武站-https://bbs.50-0.cn/791.html文章源自小武站https://1z345.cn/小武站-https://bbs.50-0.cn/791.html继续阅读
子比主题美化-悬浮侧边栏增加私信站长按钮
代码<div style="text-align: center;line-height: 20px;padding: 6px"> <div style="font-size: 16...
子比主题美化 – 修改网站整站字体
代码部署网站后台->Zibll主题设置->全局&功能->自定义代码->自定义CSS样式本文隐藏内容请注意修改下方“字体链接”为你的实际字体存放目录链接。/*自定义网站字...