快轉到主要內容

Theme

主题Grey完成

主题Grey完成

·1257 字·3 分鐘
之前有幾個朋友問我要我blog的主題,但是因為當初寫這個主題的時候只是想著自己用的,所以自定義程度很高。 而且邊用邊修改,早就离最初的样子很远很远很远了……(远目
WordPress主题修改

WordPress主题修改

·1282 字·3 分鐘
2010-07-23 18:10 # 今天突发奇想,觉得自己的主题也完善得差不多了,想试试提交到WordPress官网,结果一提交才知道自己的主题有多破陋。
技巧笔记

技巧笔记

·78 字·1 分鐘
能直接寫 html 的, 就不要用 php. 能直接寫中文的, 就不要用翻譯. 能直接表達的, 就不要有太多嵌套. 修改 css 不要一味添加, 有時刪除會更好. 影響網頁速度最嚴重的是 javascript 或 jQuery 裏的 DOM.
首頁添加文章縮圖功能

首頁添加文章縮圖功能

·113 字·1 分鐘
在 functions.php 中開啟WordPress的自帶縮圖功能。 1<?php 2 3// 支援 WordPress 2.9 的自帶縮圖功能 4 5if ( function_exists( 'add_theme_support' ) ) { add_theme_support( 'post-thumbnails' ); } ?> 在 index.php 中的the_content 之前添加以下代碼 1<?php if ( has_post_thumbnail() ) : ?> [<?php the_post_thumbnail( array( 150, 150 ), array( 'class' => 'alignleft' ) ); ?>](<?php the_permalink(); ?>) <?php endif; ?> 自帶縮圖功能目前不支持外鏈圖片。
获取WordPress分类目录列表的函数

获取WordPress分类目录列表的函数

·90 字·1 分鐘
修改主题的时候,需要显示分类目录列表,本来用的是 1<?php wp_list_categories(); ?> ,后来发现会始终显示“分类目录”四个字,十分之不美观,研究了一下,用 1<?php wp_list_cats('sort_column=name'); ?> 函数代替,解决了问题。o(* ̄▽ ̄*)o 推荐参考: https://www.renniaofei.com/tag/wordpress-tutorials/
footer的自动版权信息部分

footer的自动版权信息部分

·124 字·1 分鐘
PHP代码: 1<?php global $wpdb; 2$post_datetimes = $wpdb->get_row($wpdb->prepare("SELECT YEAR(min(post_date_gmt)) AS firstyear, YEAR(max(post_date_gmt)) AS lastyear FROM $wpdb->posts WHERE post_date_gmt > 1970")); 3 4if ($post_datetimes) { 5 $firstpost_year = $post_datetimes->firstyear; 6 $lastpost_year = $post_datetimes->lastyear; 7 $copyright = $firstpost_year; 8 if($firstpost_year != $lastpost_year) { 9 $copyright .= '-'. $lastpost_year; 10 } 11 $copyright .= ' '; 12 echo $copyright; 13 } ?> 14 < ?php bloginfo('name'); ?><?php echo get_option('home'); ?> / Theme designed by 你的大名 CSS代码: 1 #copyright { float:left; display:inline; margin:55px 0 0 -10px; color:#777; } #copyright li { float:left; display:inline; font-size:11px; margin:0 10px 0 0; padding:0 0 0 13px; background:url(img/footer_line.gif) no-repeat left center; } #copyright li a, #copyright li a:visited { text-decoration:underline; }