前几天一直在给公司做wordpress的cms主题,感觉自己设计方面实在没有天赋,于是晚上一直在找别人已经设计好的主题,在一些英文之中突然发现这个主题的的微缩图竟然有中文的,那么,像我这种懒人,考虑中文显示这类细节自然是能省就省。
ps:另一个原因是,下午骑了两个多小时的车,在联华找了个怀子,那个样子和头部的杯子挺像的。
当然对于杯子来说,它就长那样,都差不多……
很想用win wendy的主题,可是每次到了情人节(今天还是白加黑的)才发现是一个人,可以点击这里欣赏一下这个界面。
这个网站(http://rin-wendy.com/)的布局很特别,首页是三栏,左右不同的颜色,文章页根据不同的作者显示不同的颜色,页面又是一种风格。
1. 首先区分页面,首页,作者A和作者B。
- <?php if (is_page()) {
$style_item = ‘page’;
} elseif (is_single()) {
if ($post->post_author == ‘1′) {
$style_item = ‘left’;
}
elseif ($post->post_author == ‘2′) {
$style_item = ‘right’;
}
} else {
$style_item = ‘normal’;
} ?>
把定义的$style_item加在DIV框架内,以方便用CSS控制显示。
- <div id=”page” class=”wrap-<?php echo($style_item); ?>”>
2. 首页左右作者的实现可以用query_posts来控制
一开始用query_posts(’author=1′ ) 发现这样不能正常分页,查找了相关资料最后找到了如下代码:
- <?php
- $limit = get_option(’posts_per_page’);
- $paged = (get_query_var(’paged’)) ? get_query_var(’paged’) : 1;
- query_posts(’author=1′ . ‘&paged=’ . $paged);
- ?>
注意:
- <?php endwhile; ?>
下方加上一句
- <?php wp_reset_query(); ?>
不加的话会使侧栏的if (is_category())这样的判断失效。
评论部分:
1. 修改comments.php,在wp_list_comments代码那加上&callback=my_comment。
- <?php wp_list_comments(’type=comment&callback=my_comment’); ?>
2. 修改function.php,加入如下代码
- function my_comment($comment, $args, $depth) {
- $GLOBALS[‘comment’] = $comment; ?>
- <li <?php love_class(); ?> id=”li-comment-<?php comment_ID() ?>”>
- <div id=”comment-<?php comment_ID(); ?>”>
- <div class=”comment-text”>
- <div class=”comment-text-top”> </div>
- <?php comment_text() ?>
- <?php if ($comment->comment_approved == ‘0′) : ?>
- <em><?php _e(’Your comment is awaiting moderation.’) ?></em>
- <?php endif; ?>
- <?php edit_comment_link(__(’(Edit)’),’ ‘,”) ?>
- <div class=”comment-text-bot”> </div>
- </div>
- <div class=”comment-author vcard”>
- <?php echo get_avatar($comment,$size=’48′,$default=’<path_to_url>’ ); ?>
- <?php printf(__(’<cite class=”fn”>%s</cite> <span class=”says”>says:</span>’), get_comment_author_link()) ?>
- </div>
- <div class=”comment-meta commentmetadata”>
- <?php printf(__(’%1$s at %2$s’), get_comment_date(), get_comment_time()) ?>
- </div>
- </div>
- }
3. function.php,加入如下代码
- function love_class( $class = ”, $comment_id = null, $post_id = null, $echo = true ) {
- // Separates classes with a single space, collates classes for comment DIV
- $class = ‘class=”’ . join( ‘ ‘, love_comment_class( $class, $comment_id, $post_id ) ) . ‘”’;
- if ( $echo)
- echo $class;
- else
- return $class;
- }
- function love_comment_class( $class = ”, $comment_id = null, $post_id = null ) {
- global $comment_alt, $comment_depth, $comment_thread_alt;
- $comment = get_comment($comment_id);
- $classes = array();
- // Get the comment type (comment, trackback),
- $classes[] = ( empty( $comment->comment_type ) ) ? ‘comment’ : $comment->comment_type;
- // If the comment author has an id (registered), then print the log in name
- if ( $comment->user_id > 0 && $user = get_userdata($comment->user_id) ) {
- // For all registered users, ‘byuser’
- $classes[] = ‘byuser comment-author-’ . $user->user_nicename;
- // For comment authors who are the author of the post
- if ( $post = get_post($post_id) ) {
- if ( $comment->user_id === $post->post_author )
- $classes[] = ‘bypostauthor’;
- }
- }
- if ( empty($comment_alt) )
- $comment_alt = 0;
- if ( empty($comment_depth) )
- $comment_depth = 1;
- if ( empty($comment_thread_alt) )
- $comment_thread_alt = 0;
- if ( $comment_alt % 2 ) {
- if ( $comment->user_id > 0 && $user = get_userdata($comment->user_id) ) {
- $classes[] = ‘odd-’ . $user->user_login;
- $classes[] = ‘alt-’ . $user->user_login;
- } else {
- $classes[] = ‘odd’;
- $classes[] = ‘alt’;
- }
- } else {
- if ( $comment->user_id > 0 && $user = get_userdata($comment->user_id) ) {
- $classes[] = ‘even-’ . $user->user_login;
- } else {
- $classes[] = ‘even’;
- }
- }
- $comment_alt++;
- // Alt for top-level comments
- if ( 1 == $comment_depth ) {
- if ( $comment_thread_alt % 2 ) {
- $classes[] = ‘thread-odd’;
- $classes[] = ‘thread-alt’;
- } else {
- $classes[] = ‘thread-even’;
- }
- $comment_thread_alt++;
- }
- $classes[] = “depth-$comment_depth”;
- if ( !empty($class) ) {
- if ( !is_array( $class ) )
- $class = preg_split(’#\s+#’, $class);
- $classes = array_merge($classes, $class);
- }
- return apply_filters(’comment_class’, $classes, $class, $comment_id, $post_id);
- }