Answer the question
In order to leave comments, you need to log in
How to wrap an announcement (excerpt) with a link to a post in Wordpress?
The link to a Wordpress post is usually its title. How to make a link also the text of the announcement (excerpt)? I can’t create the appropriate filter in functions.php - I still don’t know much about WP.
In index.php I have this:
<?php
if ( is_search() ) {
the_excerpt();
}
else {
the_content();
edit_post_link();
}
?>
the_excerpt();
and, most likely, with a link to is_home (or is_frontpage), so that the entire text of the post does not turn out to be a link. But I don’t know how to implement it, I can’t find options for analogs of solving the problem.
Answer the question
In order to leave comments, you need to log in
Well, yes, either find it in the template the_excerpt();
and wrap it with a link, or use a filter:
add_filter( 'the_excerpt', function ($content) {
return sprintf( '<a href="%s" rel="bookmark">%s</a>', get_permalink(), $content );
} );
and, most likely, with reference to is_home (or is_frontpage), so that the entire text of the post does not turn out to be a link either
the_content()
.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question