快轉到主要內容

首頁添加文章縮圖功能

·113 字·1 分鐘
Y Cheung
作者
Y Cheung
Blogger, Programer & Traveler.

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分类目录列表的函数

·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的自动版权信息部分

·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; }

启用wp-reader-wall插件

·277 字·1 分鐘
之前一直用的灌水先锋插件由于难以调教,我把它给撤下来了。 主要是我想提高主页加载速度,不用loading头像那么久,让它排列的更好看一些,所以我不再在侧边栏放上评论者头像,而是决定另建一个新页面。其实本来灌水先锋插件也可以实现这样效果的,但是好复杂,又懒得去找教程,所以决定换啦。

WordPress宕机一日

·616 字·2 分鐘
昨天突然无法访问我的blog了,还以为我又折腾什么出错了,却发现连服务器都进不去了。大件事啦! 联系了hugege(我在他那里租的主机),说是到国内的线路抽风喔。于是,我又定了定神,没事,等它抽完了就好了。果然,晚上的时候就恢复正常了,额,也不算太正常,时不时还是抽一下,不过,能访问就好了。(^U^)ノ~YO

启用WP-RecentComments插件

·291 字·1 分鐘
因为找不回之前那个侧边栏显示最新评论排除admin评论的那段代码了,囧,所以,Google了一下,找到了这个插件。 嗯,比我想象中的还要棒。 插件下载地址:https://wordpress.org/extend/plugins/wp-recentcomments/

启用Highslide4WP插件

·100 字·1 分鐘
实现评论添加表情以弹出窗口的方式。 插件地址:(有中文汉化版)https://wordpress.org/extend/plugins/highslide4wp/ 实现与custom smiles完美结合~