电脑

Twentytwelve主题文章设置摘要

Twentytwelve是一款简明主题,但首页不能设置文章摘要,简单改动content.php文件一段代码,就可以显示文章摘要。
登录网站后台->外观->主题文件编辑器->找到content.php文件
或者FTP下载修改:路径:wp-content/themes/twentytwelve/content.php
大概40行,找到这一句:

<?php if ( is_search()) : // Only display excerpts for search. ?>

然后替换如下一句:

<?php if ( is_search() || is_category() || is_archive() || is_home()) : // Only display excerpts for search. ?>

打开博客首页,就看到已经实现显示文章摘要,其它分类同样也显示摘要了。
如果显示“继续阅读”,打开主题function.php文件,添加下面一段代码

<?php
// Add 140x140 image size
add_image_size('excerpt-thumbnail', 140, 140, true);
// Remove the ... from excerpt and change the text
function change_excerpt_more()
{
function new_excerpt_more($more)
{
// Use .read-more to style the link
return '<span class="read-more"> <a href="' . get_permalink($post->ID) . '">继续阅读&raquo;</a></span>';
}
add_filter('excerpt_more', 'new_excerpt_more');
}
add_action('after_setup_theme', 'change_excerpt_more');

 

17140cookie-checkTwentytwelve主题文章设置摘要

风雨几十载润物细无声

留言

您的电子邮箱地址不会被公开。 必填项已用*标注