WordPress根据时间显示不同主题

触手所及 | July 30, 2007

从wordpress.org.cn看来的,整理如下:
想要让wordpress能在白天和夜晚显示不同的主题样式,比如18:00~6:00显示白色theme,在6:00~18:00显示黑色theme。
很简单,首先制作两个CSS文件,分别为day.css和night.css

然后在theme的header.php 文件中,修改css的调用方式如下:

<?php if (date(”G”) >6 && date(”G”)<18){ ?>

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

<?php } else{ ?>

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

<?php }?>


J for J的個人生活, 始于公元2001. | Permalink
……更多文章,在 触手所及中找啦 | del.~ | Tech~
……或者查看標簽: , , .


2 Comments | Ping Pong

  1. 1Gravatar Icon TOP

    你这就是根据时间显示不同主题的?酷毙了

    那两个CSS和header.php放在一个目录下吗?

    Jan 15, 2008, 21:28 -
  2. 2Gravatar Icon J

    我选择的是手动切换,不是根据时间来的。
    是要放在同一个目录下,试试看。

    Jan 15, 2008, 23:18 -

JunePoetry

『静极--谁的叹嘘?

密西西比河此刻风雨,在那边攀援而走。
地球这壁,一人无语独坐。』

-- 昌耀《斯人》

令人感动的诗歌,继续阅读J推荐的诗歌»

Leave a Reply

垃圾留言渐增,烦请留下姓名和email(支持Gravatar头像)。

  • :em01:
  • :em02:
  • :em03:
  • :em04:
  • :em05:
  • :em06:
  • :em07:
  • :em08:
  • :em09:
  • :em10:
  • :em11:
  • :em12:
  • :em13:
  • :em14:
  • :em15:
  • :em16:
  • :em17:
  • :em18:
  • :em19:
  • :em20:
  • :em21:
  • :em22:

CC.All trademarks and copyrights on this page are owned by their respective owners. Comments are owned by the Poster.
The rest copyright © 2001 - 2008 J's Life, powered by WP. Theme: night or light. Entries RSS.