最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

functions - Why does modifying the "read more" link remove the link class?

programmeradmin2浏览0评论

I'm using the following code (found on the WordPress site) to modify my (more…) text:

//Modify "read more" text
function modify_read_more_link() {
    return '<a class="more-link" href="' . get_permalink() . '">(Continue…)</a>';
}
add_filter( 'the_content_more_link', 'modify_read_more_link' );

The code works as expected, in the sense that (more…) is properly replaced by (Continue…), and the link works as intended. However, there is a peculiar issue: The class more-link has disappeared, which means styling doesn't work. I attempted to circumnavigate the issue by adding styling inline (return '<a style="font-size:0.8em;" href="' . get_permalink() . '">(Continue…)</a>';) but that hasn't worked either.

My Question:
Why has the class more-link disappeared, and how can I restore it?

Note: I add the code above to functions.php; I'm not using a child theme.

I'm using the following code (found on the WordPress site) to modify my (more…) text:

//Modify "read more" text
function modify_read_more_link() {
    return '<a class="more-link" href="' . get_permalink() . '">(Continue…)</a>';
}
add_filter( 'the_content_more_link', 'modify_read_more_link' );

The code works as expected, in the sense that (more…) is properly replaced by (Continue…), and the link works as intended. However, there is a peculiar issue: The class more-link has disappeared, which means styling doesn't work. I attempted to circumnavigate the issue by adding styling inline (return '<a style="font-size:0.8em;" href="' . get_permalink() . '">(Continue…)</a>';) but that hasn't worked either.

My Question:
Why has the class more-link disappeared, and how can I restore it?

Note: I add the code above to functions.php; I'm not using a child theme.

Share Improve this question edited Nov 7, 2020 at 8:59 asked Nov 6, 2020 at 10:36 user176615user176615 1
  • Above code is working as expected. May be some plugin is affecting the hook. Try disabling all plugins. – Nilambar Sharma Commented Nov 9, 2020 at 5:47
Add a comment  | 

1 Answer 1

Reset to default 0 +50

Perhaps there is an issue with the "Ellipsis" HTML character you are using?

function modify_read_more_link() {
    return '<a class="more-link" href="' . get_permalink() . '">( Continue &hellip; )</a>';
}
add_filter( 'the_content_more_link', 'modify_read_more_link' );
发布评论

评论列表(0)

  1. 暂无评论