• Blogging News
  • Blogging Resource
  • Blogging tips
  • Blogging tutorials
  • Interview
  • Links Post
  • Personal logs
  • Reviews
  • WordPress Tips
  • Wordpress tips –如何为特定页面使用特定样式表

    1. 样式表简介

    样式表(Stylesheet)是一个WordPress主题的重要组成部分之一,它负责控制整个主题的所有样式,包括:字体,颜色,图片,链接,模块的位置等等. 一般来说一个WordPress主题拥有一个样式表文件(style.css),你可以在后台的主题编辑器中查看现在使用主题的所有组成文件。

    2.如何为你的特定页面使用另一个样式表。

    (1) 应用实例

    <a> 比如你撰写了一个contact me的页面,想要为这个页面自定义另外一个样式,让它与主题中的其他页面不同

    <b> 你的某个分类(比如blogging tips)比较受读者欢迎,你想为这个分类定义特定的样式。

    (2) 如何实现

    样式表(Stylesheet)的使用一般是在主题的 header.php文件中定义的,打开你的header.php找到以下的语句:

    <link rel=”stylesheet” href=”<?php bloginfo(’stylesheet_url’); ?>” type=”text/css” media=”screen” />

    以上语句说明了主题调用主题文件夹中的stlye.css文件。
    如果想要为特定的一个分类定义一个另一个样式表的话只需要将代码改成:

    <?php if ( is_category(’1′) ) {
    <link rel=”stylesheet” href=”<?php bloginfo(’template_url’); ?>/cat-1.css”
    type=”text/css” media=”screen” />;
    <?php } else { ?>
    <link rel=”stylesheet” href=”<?php bloginfo(’stylesheet_url’); ?>”
    type=”text/css” media=”screen” />
    <?php } ?>

    以上语句说明,对你指定的分类使用cat-1.css,对其他的则仍然使用的style.css. (当然,需要将自定义的cat-1.css上传到主题文件夹中)

    13条留言

    (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.