×

Wordpress教程

用WordPress过滤器替换”read more”字样(wordpress修改)

星花园站长资源网 星花园站长资源网 发表于2024-06-28 浏览6566 评论0
"read more"是个好东西,方便你把长文章截断,保持主页的整洁。但问题是你无法替换"read more"的文字。下面告诉你替换的方法。老样子,打开function.php,插入以下代码:<?php $custom_more = "Continue reading this post"; //替换后的文字 add_filter( 'the_content_more_link', 'my_more_link', 10, 2 ); function my_more_link( $more_link, $more_link_text ) { return str_replace( $more_link_text, $custom_more, $more_link );}?>大功告成!

Wordpress教程

如安在摘抄中显现Read More

星花园站长资源网 星花园站长资源网 发表于2024-06-19 浏览5251 评论0
为了避免重复的内容,减少网站的加载时间,也为了更好的SEO,许多博客开始使用摘录,他是在分页面或者是主页面上的小型文章描述。WordPress默认的是,并包含一个链接。这段代码需要放在functions.php文件<?php  ?>里 // Changing excerpt more function new_excerpt_more($more) { global $post; return '… <a href="'. get_permalink($post->ID) . '">' . 'Read More &raquo;' . '</a>'; } add_filter('excerpt_more', 'new_excerpt_more');

Wordpress教程

用WordPress过滤器替换&#8221;read more&#8221;字样(wordpress修改)

星花园站长资源网 星花园站长资源网 发表于2024-05-31 浏览5153 评论0
"read more"是个好东西,方便你把长文章截断,保持主页的整洁。但问题是你无法替换"read more"的文字。下面告诉你替换的方法。老样子,打开function.php,插入以下代码:<?php $custom_more = "Continue reading this post"; //替换后的文字 add_filter( 'the_content_more_link', 'my_more_link', 10, 2 ); function my_more_link( $more_link, $more_link_text ) { return str_replace( $more_link_text, $custom_more, $more_link );}?>大功告成!