
wordpress在发布文章时候如何自动添加meta name='description'描述,下面web建站小编给大家详细介绍一下具体实现代码!
打开主题下functions.php,新增以下代码:
function wp_auto_desc() {
global $post;
if (!is_single()) { return; }
$meta = strip_tags($post->post_content);
$meta = strip_shortcodes($post->post_content);
$meta = str_replace(array("\n", "\r", "\t"), ' ', $meta);
$meta = substr($meta, 0, 300);//描述字数
echo "";
}
add_action('wp_head', 'wp_auto_desc');
php语法对index.php首页进行判断(根据需要显示不同页面)
wordpress新建页面中页面属性里没有“模板”选项解决方法
标签: description, wordpress教程, 自动添加描述
上面是“wordpress发布文章时自动添加description描述”的全面内容,想了解更多关于 wordpress 内容,请继续关注web建站教程。
当前网址:https://m.ipkd.cn/webs_3525.html
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

Tiny-R1-32B:一款由360公司与北京大学联合研发的中等量级推理模型
美图秀秀批量处理
世界各国网址大全官网首页入口