There are several options you have. You can write your own excerpt, or just use the tools which WordPress offers to you.
There are three options you have:
- Use WordPress core function the_excerpt();
- Use WordPress core function get_the_excerpt();
- Use WordPress filter wp_trim_excerpt();
The easiest and propably most fitting for you is the first one.
<?php
// WordPress template function
the_excerpt();
?>
Excerpt from official WordPress docs:
Displays the excerpt of the current post after applying several filters to it including auto-p formatting which turns double line-breaks into HTML paragraphs. It uses get_the_excerpt() to first generate a trimmed-down version of the full post content should there not be an explicit excerpt for the post.
Now, you want to add a “read more custom link”.
Basically, the first step is to add a WordPress filter to the excerpt.
The filter we are using is called excerpt_more.
<?php
// Mechanism to add a filter to something
function functionname() {
// Custom code to filter/modify
}
add_filter('filtername', 'functionname');
?>
The next step is to call the excerpt function where you want it.
<?php
// Put these 3 lines of code in your functions.php
function wpdocs_excerpt_more( $more ) {
return '<a href="'.get_the_permalink().'">Permalink</a>';
}
add_filter( 'excerpt_more', 'wpdocs_excerpt_more' );
// This function call needs to be placed within "the loop" of your home.php
the_excerpt();
?>
The function “the_excerpt” needs to be called within the loop. So, make sure you are adding it in the correct place.