图片延迟加载
1.加载jquery lazyload插件,并启用
2.修改%theme%index.php
在get_header()下面增加js:
<script type="text/javascript">
jQuery(function() {
jQuery("img").lazyload({
effect : "fadeIn"
});
});
</script>
3.修改/wp-includes/media.php
function wp_get_attachment_image
关闭评论
%theme%/function.php
function close_comments( $posts ) {
if ( !is_single() ) { return $posts; }
if ( time() - strtotime( $posts[0]->post_date_gmt ) > ( 1 ) ) {
$posts[0]->comment_status = 'closed';
$posts[0]->ping_status = 'closed';
}
return $posts;
}
add_filter( 'the_posts', 'close_comments' );
删除前台头部无用LINK
%theme%/function.php
remove_action( 'wp_head', 'feed_links_extra', 3 ); // Display the links to the extra feeds such as category feeds
remove_action( 'wp_head', 'feed_links', 2 ); // Display the links to the general feeds: Post and Comment Feed
remove_action( 'wp_head', 'rsd_link' ); // Display the link to the Really Simple Discovery service endpoint, EditURI link
remove_action( 'wp_head', 'wlwmanifest_link' ); // Display the link to the Windows Live Writer manifest file.
remove_action( 'wp_head', 'index_rel_link' ); // index link
remove_action( 'wp_head', 'parent_post_rel_link', 10, 0 ); // prev link
remove_action( 'wp_head', 'start_post_rel_link', 10, 0 ); // start link
remove_action( 'wp_head', 'adjacent_posts_rel_link', 10, 0 ); // Display relational links for the posts adjacent to the current post.
remove_action( 'wp_head', 'wp_generator' ); // Display the XHTML generator that is generated on the wp_head hook, WP version
关闭RSS
%theme%/function.php
/**
* disable feed
*/
function fb_disable_feed() {
wp_die( __('No feed available,please visit our <a href="'. get_bloginfo('url') .'">homepage</a>!') );
}
add_action('do_feed', 'fb_disable_feed', 1);
add_action('do_feed_rdf', 'fb_disable_feed', 1);
add_action('do_feed_rss', 'fb_disable_feed', 1);
add_action('do_feed_rss2', 'fb_disable_feed', 1);
add_action('do_feed_atom', 'fb_disable_feed', 1);
twentytwelve删除google字体css引用
%/twentytwelve/functions.php文件中的twentytwelve_scripts_styles函数
if ( false && 'off' !== _x( 'on', 'Open Sans font: on or off', 'twentytwelve' ) )
优化 WordPress 头部 header.php
浏览器们可以根据自己设定的默认样式来呈现网页,比如你把朋友定义成 friend,而我要按照拼音来定义成 pengyou,彼此之间无法统一,该 功能就变得没有丝毫的意义。所以我们在HTML文档的标签中使用 profile 属性引入一个声明,声明在这个 HTML 文档中使用了 XML Friends Network (XFN) 微格式,然后按照这份XFN微格式中约定的方式来描述关系网络,于是即使是不同用户代理器访问这些数据只要其遵循XFN的约定即可正确的读取出其中的关系数据。
pingback 自己本身就是麻烦事,不需要。
调用谷歌字体,明显就是多余,我都不用这些字体。
显示页面加载时间
在模板的适当位置插入一个简单的代码,可以知道花费了多少时间来加载网页。这个小提示很好的让你了解你的WordPress的优化。
<? echo get_num_queries();?> queries in <? timer_stop(1); ?> seconds.