首页 >

WordPress标题标签title的写法

WordPress最常用的标题标签是wp_title函数,所以在此之前,一定要好好了解函数。

用法一

主页:博客名 – 博客描述

主页翻页:博客名 -第 2 页

其它页面:页面名 – 博客名

其它页面:页面名 – 博客名-第 2 页

<?phpif(is_home() && !is_paged()){$title=get_bloginfo('name').' – '.get_bloginfo('description');}else{$title=wp_title(' - ',true,'right');bloginfo('name');}if($paged

如果你想在主页上显示:博客名称 – 博客描述-第 2 页

只需要去除if语句中的&& !is_paged()

此外,我还摘录了官方默认主题twentyeleven标题写法:

<?php/** Print the <?php/** Print the <title> tag based on what is being viewed.*/global $page, $paged;wp_title( "-", true, "right" );// Add the blog name.bloginfo( "name" );// Add the blog description for the home/front page.$site_description = get_bloginfo( "description", "display" );if ( $site_description && ( is_home() 
		<div class="tag"></div>
	</div><!-- .entry-content -->
<hr>
<li>暂无相关文章</li>	 <footer class="entry-footer">
		<span class="cat-links">Posted in <a href="https://www.liuzhongwei.com/topics/wordpress" rel="category tag">wordpress</a></span>	</footer><!-- .entry-footer -->
<!-- #post-## -->

	<nav class="navigation post-navigation" aria-label="文章">
		<h2 class="screen-reader-text">文章导航</h2>
		<div class="nav-links"><div class="nav-previous"><a href="https://www.liuzhongwei.com/page/1257969.html" rel="prev">mysql慢查询方法有哪些 |mysql initlized</a></div><div class="nav-next"><a href="https://www.liuzhongwei.com/page/427416.html" rel="next">php教程api技术,如何突破PHP程序员的瓶颈期 – PHP基础 – 前端,基于php的外国文献综述</a></div></div>
	</nav>
		</main><!-- #main -->
	</section><!-- #primary -->


<aside id="secondary" class="widget-area col-sm-12 col-md-12 col-lg-4" role="complementary">
<hr>
	<section id="block-4" class="widget widget_block">
<hr class="wp-block-separator has-alpha-channel-opacity"/>
</section></aside><!-- #secondary -->
			</div><!-- .row -->
		</div><!-- .container -->
	</div><!-- #content -->
    

	<footer id="colophon" class="site-footer" role="contentinfo">
		<div class="container">
            <div class="site-info">
                © 牛的日记 | www.liuzhongwei.com <br> 网站部分内容来源于网友供稿,若有侵权请联系删除,970928#QQ.com<br>
                           </div><!-- close .site-info -->
		</div>
	</footer><!-- #colophon -->
</div><!-- #page -->
	<!--colorcode_start-->
	<script type="text/javascript" src="https://www.liuzhongwei.com/wp-content/plugins/colorcode/js/wp-colorcode.js?ver=20121102"></script>
	<script type="text/javascript">
		window.onload = function() {
			DlHighlight.HELPERS.highlightByName('colorcode', 'pre','', false);
		} 
	</script>	
	<!--colorcode_end-->


<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?362c2492cf3ac506a1c032629e391abd";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script>

</body>
</html>