HTTP/1.0 200 OK
Date: Tue, 17 Jun 2008 01:10:03 GMT
Server: Apache
X-Powered-By: PHP/5.2.5
X-Pingback: http://www.keycn.com/xmlrpc.php
Vary: Accept-Encoding,User-Agent
Content-Type: text/html; charset=UTF-8
X-Cache: MISS from domain.net
Via: 1.0 domain.net:80 (squid)
Connection: close
Keycn
Home
About
Keycn
Hold fast to dreams,For if dreams die,Life is a broken-winged bird,That cannot fly.Hold fast to dreams,For when dreams go,Life is a barren field,Frozen with snow.—Langston Hughs
Author: key
Posted on: June 16th, 2008
Posted in: wordpress
Comments: No Comments
不同分类定义不同颜色
有时候,我们想实现不同分类的标题和链接的颜色各不一样,怎么办呢?其实很简单,下面就说一下方法,只需要修改模板文件index.php和single.php即可。
1,打开index.php和single.php文件,找到如下代码:
1
<div class="post" id="post-<?php the_ID(); ?>">
2,修改为
1
2
3
4
<div id="post-<?php the_ID(); ?>"
<?php if(in_category('1')) {echo('class="post cat-1"');} ?>
<?php if(in_category('2')) {echo('class="post cat-2"');} ?>
>
3,添加css
1
2
3
4
5
6
7
.cat-1 a {
color: #000;
}
.cat-2 a {
color: #eee;
}
Author: key
Posted on: June 16th, 2008
Posted in: wordpress
Comments: No Comments
怎么高亮显示动态菜单
方法一:
1,代码如下:
1
2
3
4
<ul id="nav">
<li<?php if ( is_home() || is_category() || is_archive() || is_search() || is_single() || is_date() ) { echo ' class="current"'; } ?>><a href="#">Home</a></li>
<li<?php if ( is_page('about') ) { echo ' class="current"'; } ?>><a href="#">About</a></li>
</ul>
假如当前页面是首页(Home)或目录页(Category)或存档页(Archive)或搜索结果页(Search)或单篇日志页面(Single), class=”current” 属性将会自动加入到第一个列表条目的 li 标签中,它将会高亮显示该按钮;假如当前页面的缩略名是“about”时,class=”current” 属性将自动加入第二个列表条目的 li 标签中。
2,添加CSS
1
2
3
.current {
background: #000;
}
方法二:
1,代码如下:
1
2
3
4
<ul id="nav">
<li class="<?php if (((is_home()) && !(is_paged())) or (is_archive()) or (is_single()) or (is_paged()) or (is_search())) { ?>current_page_item<?php } else { ?>page_item<?php } ?>"><a href="<?php echo get_settings('home'); ?>">Home</a></li>
<?php wp_list_pages('sort_column=menu_order&depth=1&title_li=');?>
</ul>
2,添加css
1
2
3
.current_page_item {
background: #000;
}
Author: key
Posted on: June 16th, 2008
Posted in: wordpress
Comments: No Comments
怎么区分作者评论
当评论很多时,常常看不清楚作者的评论,有没有区分作者评论的办法呢?当然有些插件能实现这个功能.下面我提供一个简单方法,以e-mail来做区分,只需要修改default模板的comments.php文件即可.
1,打开comments.php文件,找到如下代码:
1
<li class="<?php echo oddcomment; ?>" id="comment-<?php comment_ID() ?>">
2,修改为:
1
<li class="<?php if (comment->comment_author_email == "author@domain.com") echo author; else echo oddcomment; ?>" id="comment-<?php comment_ID() ?>">
其中author@domain.com请以作者email代替.
3,在style.css文件里添加css代码:
1
2
3
li.author {
background-color: #eee;
}
4,如果有多个作者,可将代码修改为:
1
<li class="<?php if (comment->comment_author_email == get_the_author_email()) echo author; else echo oddcomment; ?>" id="comment-<?php comment_ID() ?>">
5,如果要区分特殊用户,可修改代码为:
1
<li class="<?php if (comment->comment_author_email == "author@domain.com") echo author; else if (comment->comment_author_email == "guest1@domain.com") echo guest1; else if (comment->comment_author_email == "guest2@domain.com") echo guest2; else echo oddcomment; ?>" id="comment-<?php comment_ID() ?>">
分别对guest1,guest2添加样式即可.
Author: key
Posted on: June 15th, 2008
Posted in: Uncategorized
Comments: 1 Comment
Hello world!
Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!
Latest Posts
不同分类定义不同颜色
怎么高亮显示动态菜单
怎么区分作者评论
Hello world!
Archives
June 2008
Meta
Log in
Valid XHTML
XFN
WordPress
© 2008 keyCN.
XHTML,
CSS,
WordPress.
Entries Feed
Comments Feed