
AccessPress Mag 是一个灵活且现代的免费 WordPress 杂志主题,它是完全响应和SEO优化的WordPress主题,适用于在线杂志、新闻网站、编辑相关的项目、博客或个人网站。
AccessPress Mag 可以搭建内容强大的网上博客,是搜索引擎优化专家、设计师和记者的理想解决方案。它的功能包括:两种文章布局、作者盒子、特色图片、社交媒体集成更广泛的社交圈。
WordPress 免费新闻杂志CMS主题 AccessPress Mag 中文使用帮助手册系列:
为了方便大家使用,翻译了英文使用手册。可以点击上面的链接查看。
在使用 AccessPress Mag 主题的过程中,发现首页对中文的支持不是很好,主要是没有支持中文字符的内容截取,导致排版失效,文章所有的字符内容都到首页上显示了。
需要把 function accesspress_mag_word_count( $string, $limit ) 函数中的字符拼接 implode( ‘ ‘, mb_substr( $words, 0, $limit )); 直接修改为支持 WordPress 中文字符截取的 mb_substr( $string, 0, $limit );
在路径:/wp-content/themes/accesspress-mag/inc/ 中的 accesspress-functions.php 文件中 第529行中的代码
将原有的代码:
$words = explode( ' ', $string );
return implode( ' ', array_slice( $words, 0, $limit ));
修改为:
return mb_substr( $string, 0, $limit );
修改后,函数为:
if( ! function_exists( 'accesspress_mag_word_count' ) ):
function accesspress_mag_word_count( $string, $limit ) {
$string = strip_tags( $string );
$string = strip_shortcodes( $string );
//$words = explode( ' ', $string );
//return implode( ' ', array_slice( $words, 0, $limit ));
return mb_substr( $string, 0, $limit );
}
endif;
在路径:/wp-content/themes/accesspress-mag/ 中的 home-page.php 是 AccessPress Mag 主题的首页文件,这里将第二个模块的截取数改为了265
<?php if( $b_counter == 1 ) { ?><div class="post-content"><?php echo '<p>'. accesspress_mag_word_count( get_the_content(), 265 ) .'</p>' ;?></div><?php } ?>
结果如图所示: