![](/img/trans.png)
[英]How to add content after my post title on Wordpress ? Only on the post title
[英]How to Add post title to content description?
使用此代码
<?php
$post = $wp_query->post;
$descrip = strip_tags($post->post_content);
$descrip_more = '';
if (strlen($descrip) > 155) {
$descrip = substr($descrip,0,155);
$descrip_more = ' ...';
}
$descrip = str_replace('"', '', $descrip);
$descrip = str_replace("'", '', $descrip);
$descripwords = preg_split('/[\n\r\t ]+/', $descrip, -1, PREG_SPLIT_NO_EMPTY);
array_pop($descripwords);
$descrip = implode(' ', $descripwords) . $descrip_more; $descrip = strip_shortcodes($descrip );
echo '<meta name="description" content="'.$descrip.'">'; ?>
在我的标题中输出如下内容:
<meta name="description" content=" Everything year life dont know why but ...">
我想知道是否可以在代码中添加一些内容,以便在内容的开头“每年的岁月都不知道为什么……”部分之前添加单个帖子标题。
也许是这样吗?
<meta name="description" content=" Uverworld - nano second (<-- the post title) Everything year life dont know why but ...">
换一种说法
<meta name="description" content=" Uverworld - nano second Everything year life dont know why but ...">
-
上面的代码在内容之前还留有很多空间,并显示出来,就像有没有办法摆脱它吗?
您可以执行以下操作:
<meta name="description" content="<?php echo get_the_title(); ?> Everything year life dont know why but ...">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.