• Blogging News
  • Blogging Resource
  • Blogging tips
  • Blogging tutorials
  • Interview
  • Links Post
  • Personal logs
  • Reviews
  • WordPress Tips
  • WordPress Tips –如何自定义导航栏上的页面

    主题头部的导航栏可以帮助你展示不同的页面,比如 About me, 存档页 ,友情链接等,从而提高Blog的导航能力和互动性。

    在WordPress主题中一般有两种定义导航栏的方式:
    1. 调用函数展示页面 :

    <?php wp_list_pages(’depth=1&title_li=’); ?>

    这个语句的意思是调用wordpress中的页面,也就你是在后台–撰写的所有页面(page)将会被按顺序显示。

    Tips:如果由于自己的页面比较多或者导航栏空间有限,不想列出所有的页面,那么可以通过以下方式实现:

    后台–Manage(管理)–Pages(页面) 中查看页面,可以看到每个页面都有一个ID

    然后把上面的调用语句改为以下:

    <?php wp_list_pages(’title_li=&depth=1&exclude=6,4′); ?>

    这样可以展示除了ID为4 和6的所有page.

    <?php wp_list_pages(’title_li=&depth=1&include=6,4′); ?>

    这样可以实现只展示ID为4和6的page.

    2. 自定义html语句展示页面:

    <a href=”http://www.moon-blogger.com”>HOME</a>
    <a href=”http://www.moon-blogger.com/friends”>VISITORS</a>
    <a href=”http://www.moon-blogger.com/archives”>ARCHIVES</a>
    <a href=”http://www.moon-blogger.com/friendly-link”>LINKS</a>

    这样的定义方法自由性更大, 使用静态的html也有利于提高加载速度,之前在《5个技巧为你的Wordpress提速》中已经详细的介绍过了。

    Related posts

    8条留言

    (Required)
    (Required, not published)

    Who is behind this blog?

    My name is Jacky,a college student in China at present.Blogging is one of my hobbies.I ran this blog to bring in useful blogging tips and skills from the top bloggers in foreign countries since I find there still remains a gap between our chinese blogs and foreigners'.I also want to help the greenhands who have just started blogging and may be not familiar with wordpress.I am looking forward to being your friend.Feel free to connect with me.