Always Show the "Read More" Link When Using the Astra Theme
In post archives, WordPress mostly shows a post excerpt instead of the full post, followed by a “Read more” link. If your post contains tags like “pre” or “code” (and many more), the content of these tags will be removed from the excerpt. This can lead to conditions, where the excerpt does not show the full post, but no read more link is shown (because WordPress removes the “invalid” tags first and then checks for the length).
If you use the Astra Theme, you only have to add some lines of code to your child theme to always show the “Read more” link. The lines of code you have to add are:
add_action(
'after_setup_theme',
function () {
// Remove "Read more", conditionally added by astra
remove_filter('excerpt_more', 'astra_post_link', 1);
// Add "Read more" to every post
add_filter(
'the_excerpt',
function ($content) {
return $content . astra_post_link();
},
99
);
// Remove "..." added by astra
add_filter(
'astra_post_link',
function ($value) {
return str_replace("…", "", $value);
}
);
}
);
Now, a “Read more” link should appear after every post.
Related Posts
- Always show "Read more" when using GeneratePress
- Modify 'Read more...' link
- Disable Google Fonts Loading When Using the Astra Theme
- Use FacetWP with the Astra Theme
- Disable 'Jump' When Clicking 'Read more...'
- Debug WordPress SQL Queries
- Right Align 'Read more' Using Genesis Framework
- Right Align 'Read more'