阅读更多摘录wordpress

阅读更多摘录wordpress,wordpress,hyperlink,Wordpress,Hyperlink,我已经回顾了其他类似于我的问题的帖子,但我肯定遗漏了一些东西。 我在我的页面中添加了如下摘录: [title size="2"]LATEST ARTICLES[/title] [recent_posts columns="4" number_posts="12" cat_id="" thumbnail="yes"  excerpt="yes" title="yes"] [/recent_posts] 我试着做两件事 设置摘录的长度 让它链接到文章不一定是阅读更多的链接点是好的 我曾尝试将摘录手

我已经回顾了其他类似于我的问题的帖子,但我肯定遗漏了一些东西。 我在我的页面中添加了如下摘录:

[title size="2"]LATEST ARTICLES[/title]
[recent_posts columns="4" number_posts="12" cat_id="" thumbnail="yes"  excerpt="yes" title="yes"] [/recent_posts]
我试着做两件事

设置摘录的长度 让它链接到文章不一定是阅读更多的链接点是好的 我曾尝试将摘录手动添加到页面的摘录区域屏幕选项中,但这并没有覆盖Wordpress的内容

在我的function.php文件中,我使用

add_filter('the_excerpt', 'do_shortcode');
这是可行的,但当我试图在下面添加额外的代码时,它没有任何作用。我需要修改rphp文件才能注册吗

`enter code here`function new_excerpt_more($more) {
return '<a href="'. get_permalink($post->ID) . '">' . ' read on ..' . '</a>';
}
add_filter('excerpt_more', 'new_excerpt_more');

function new_excerpt_length($length) {
return 46;
}
add_filter('excerpt_length', 'new_excerpt_length');

我已通过以下代码实现了您期望的结果:

function custom_excerpt_length( $length ) {
  return 46;
}
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );

function new_excerpt_more( $more ) {
  return ' <a class="read-more" href="'. get_permalink( get_the_ID() ) . '">' . __('Read More', 'your-text-domain') . '</a>';
}
add_filter( 'excerpt_more', 'new_excerpt_more' );