如何给wordpress的page页面添加关键字和描述

2025-03-11 00:31:50
推荐回答(3个)
回答1:

具体方法如下:

1、进入后台,如图所示,找到外观——编辑

2、   然后在编辑主题的右边,找到header.php文件,如图点击打开

3、在头部header.php文件中,找到代码,这代码表示标题结束的意思,我们就在标题的后面加入关键词和描述代码,如图所示,找到后,请按回车键空出一行,方便我们下一步添加代码

4、按照步骤三空出一行后,请先修改下面代码



一般网站的关键词和描述都是站长自己定的,请根据网站需要,修改上面的关键词和描述,然后把代码放进刚才第三步空出的那一行,然后再点击下面的更新提交,自此wordpress的关键词和描述添加完毕。

回答2:

WP开发21:wordpress网站文章页模板,如何调用文章的标题、内容、标签等信息?

回答3:

如果你会写代码就方便,不会的话建议还是使用All in One SEO Pack插件,这样方便很多。
用插件应该不会像你说的那样不会显示,你直接用浏览器的源代码看看,或许你在站长工具那的缓存,所以没显示出来。
用代码的方法为:
把以下代码放header.php文件中的标题之下。<br><br>1<br>2<br>3<br>4<br>5<br>6<br>7<br>8<br>9<br>10<br>11<br>12<br>13<br>14<br>15<br>16<br>17<br>18<br>19<br>20<br>21<br>22<br>23<br>24<br>25<br>26<br>27<br>28<br>29<br>30<br>31<br>32<br>33<br>34<br>35<br>36<br>37<br>38<br>39<br>40<br>41<br>42<br>43<br>44<br>45<br>46<br>47<br>48<br>49<br>50<br>51<br>52<br>53<br>54<br>55<br>56<br>57<br>58<br>59<br>60<br>61<br>62<br>63<br> <br><?php<br>if (is_home()) {<br> $keywords = $options['keywords'];<br> $description = $options['description'];<br>}elseif (is_single()) {<br> $tags = wp_get_post_tags($post->ID);<br> foreach ($tags as $tag ) {$title_tags = $title_tags .$tag->name ."|"; $keywords = $keywords .$tag->name .",";}<br> $title_tags = substr($title_tags,0,-1);<br> if($title_tags) $title_tags = '|'.$title_tags;<br> $keywords = substr($keywords,0,-1);<br> if (has_excerpt()) {<br> $description = get_the_excerpt();<br> }else {<br> $description = mb_strimwidth(strip_tags(apply_filters('the_content',$post->post_content)),0,220,"...");<br> $description = str_replace("\n","",$description);<br> $description = empty($description)? $keywords : $description;<br> }<br>}elseif (is_category()) {<br> $keywords = single_cat_title("", false);<br> if ($paged > 1){<br> $description = trim(strip_tags(category_description($cat_ID))).' - '.get_bloginfo('name').'第'.$paged.'页。';<br> }else{<br> $description = trim(strip_tags(category_description($cat_ID)));<br> }<br>}elseif (is_page()) {<br> $keywords = get_the_title("", false);<br> $description = mb_strimwidth(strip_tags(apply_filters('the_content',$post->post_content)),0,220,"...");<br>}elseif (is_tag()) {<br> $keywords = single_tag_title("", false);<br> if ($paged > 1){<br> $description = trim(strip_tags(tag_description($tag_id))).' - '.get_bloginfo('name').'的'.single_tag_title('',false).'的标签存档文章-第'.$paged.'页。';<br> }else{<br> $description = trim(strip_tags(tag_description($tag_id))).' - '.get_bloginfo('name').'的'.single_tag_title('',false).'的标签存档文章。';<br> }<br>}elseif (is_day()) {<br> $keywords = get_the_time('Y年m月d日');<br> if ($paged > 1){<br> $description = get_bloginfo('name').get_the_time('Y年m月d日').'的存档文章-第'.$paged.'页。';<br> }else{<br> $description = get_bloginfo('name').get_the_time('Y年m月d日').'的存档文章。';<br> }<br>}elseif (is_month()) {<br> $keywords = get_the_time('Y年m月');<br> if ($paged > 1){<br> $description = get_bloginfo('name').get_the_time('Y年m月').'的存档文章-第'.$paged.'页。';<br> }else{<br> $description = get_bloginfo('name').get_the_time('Y年m月').'的存档文章。';<br> }<br>}elseif (is_year()) {<br> $keywords = get_the_time('Y年');<br> if ($paged > 1){<br> $description = get_bloginfo('name').get_the_time('Y年').'的存档文章-第'.$paged.'页。';<br> }else{<br> $description = get_bloginfo('name').get_the_time('Y年').'的存档文章。';<br> }<br>}elseif(is_search()) {<br> $keywords = $s;<br> $description = get_bloginfo('name').$s.'的搜索结果。';<br>}elseif(is_404()) {<br> $keywords = '404,错误页面';<br> $description = '404错误,未找到你需要的页面,请返回首页。';<br>}<br>?></p> </div> </div> <div class="clear"></div> </div> </div> </div> <div class="wendaright"> <div class="wdluluerwema"> <div class="wdxgwttop">相关问答</div> <div class="wdxgwtnr"> </div> <div class="clear"></div> </div> <!-- 其他随机问答['id'=>alphaID($like['zid'])] --> <div class="wdluluerwema"> <div class="wdxgwttop">最新问答</div> <div class="wdxgwtnr"> <div class="wdxgwtcont"> <div class="wdxgtitle"><a href="https://www.51a.net/1179207914623866659.html">GF和BF是什么意思</a></div> </div> <div class="wdxgwtcont"> <div class="wdxgtitle"><a href="https://www.51a.net/1606684606557790387.html">数字电视(机顶盒)e05-不认识IC卡怎么办?</a></div> </div> <div class="wdxgwtcont"> <div class="wdxgtitle"><a href="https://www.51a.net/401752685362243965.html">三体是什么?</a></div> </div> <div class="wdxgwtcont"> <div class="wdxgtitle"><a href="https://www.51a.net/1894199846820403220.html">细胞工程的概念是什么</a></div> </div> <div class="wdxgwtcont"> <div class="wdxgtitle"><a href="https://www.51a.net/1496698041815992099.html">如何学习外语 How to Learn a Foreign Language</a></div> </div> <div class="wdxgwtcont"> <div class="wdxgtitle"><a href="https://www.51a.net/1112479132165437579.html">梦见被人追杀逃也逃不掉,还被活剥了皮肉,只剩骨头了,这样的梦好不好?</a></div> </div> <div class="wdxgwtcont"> <div class="wdxgtitle"><a href="https://www.51a.net/353769791.html">汽轮机盘车手动啮合操作步骤?</a></div> </div> <div class="wdxgwtcont"> <div class="wdxgtitle"><a href="https://www.51a.net/630218671358409164.html">win10系统中本地连接显示未启用dhcp是什么意思?</a></div> </div> <div class="wdxgwtcont"> <div class="wdxgtitle"><a href="https://www.51a.net/1774228130699991020.html">你好!我购买了椅子套,不能使用、要求退货退款?</a></div> </div> <div class="wdxgwtcont"> <div class="wdxgtitle"><a href="https://www.51a.net/1834644117764024700.html">以孔子思想为例,结合现实,谈谈传统与当代之间的关系1500字</a></div> </div> </div> </div> </div> <div class="clear"></div> <div class="footer"> <!-- 移动底部导航 --> <div class="fanhuitop"><a href="#top" ref="nofollow"><img src="https://www.51a.net/static/old/img/fhtop.png" alt="返回顶部" title="返回顶部"></a></div> <div class="dibu"> <div class="dibu"> </div> </div> <div class="banquan"> <p>内容全部来源于网络收集,如有侵权,请联系网站删除:QQ号:24596024</p> </div> </div> </div> </div> <script> var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?aa60e2f779ee696abd6a207eac06903d"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script> </body> </html>