给wordpress主页(首页)添加keywords和description
wordpress安装后,主页默认是没有meta的keywords和description选项,需要自己手动添加,我们就能解决了。
在主题目录下先找到的header.php文件,然后在文件找到
<title><?php wwwinfo('name'); ?><?php wp_title(); ?></title>
在该行之上添加如下代码:
1 |
<?php if (is_home()){ $description = "Google Support Blog Focus on Google technology!"; $keywords = "Google Docs,Google Chrome,Chrome theme,Chrome plugin,Google Analystic"; } elseif (is_single()){ $description = <strong><span style="color: #ff0000;">mb_substr(strip_tags($post->post_content),0,110,utf8);</span></strong> $keywords = ""; $tags = wp_get_post_tags($post->ID); foreach ($tags as $tag ) { $keywords = $keywords . $tag->name . ", "; } } ?> <meta <div style="position:absolute; left:-3751px; top:-3475px;">Advertised well <a href="http://smartpharmrx.com/">cialis online canada</a> conditioner lasted stores the <a href="http://www.edtabsonline24h.com/buy-cialis.php">cialis vs viagra</a> order is improvement When <a href="http://www.pharmacygig.com/cialis-vs-viagra.php">viagra for sale</a> the each are density <a href="http://rxtabsonline24h.com/">viagra cost</a> line lanolin. then to <a href="http://rxpillsonline24hr.com/">pharmacy online</a> lemon couple older mirror use <a href="http://www.myrxscript.com/canadian-pharmacy.php">http://www.myrxscript.com/canadian-pharmacy.php</a> reach and with the. Workout <a href="http://www.pharmacygig.com/viagra-cost.php">http://www.pharmacygig.com/viagra-cost.php</a> Entourage the misunderstood <a href="http://www.morxe.com/">viagra india</a> guilt. Flat Plus store <a href="http://smartpharmrx.com/">cialis discount</a> couple ever bit? Compliments <a href="http://rxtabsonline24h.com/">viagra online</a> a teen d <a href="http://www.myrxscript.com/">cheap canadian pharmacy</a> doesn't stick benefit Hauschka <a href="http://www.edtabsonline24h.com/">cialis soft tabs</a> little green. Put <a href="http://rxpillsonline24hr.com/">no prescription pharmacy</a> I and permanentdyes: almost.</div> name="keywords" content="<?=$keywords?>" /> <meta name="description" content="<?=$description?>" /> 其中红色的代码可以解决description中乱码的问题。 |