Home › Forum › Customization › Make the_excerpt() clickable
This topic contains 5 replies, has 2 voices, and was last updated by StartupWP 6 years, 2 months ago.
- AuthorPosts
- December 30, 2012 at 6:48 AM #357
I want my site to show excerpts everywhere (start page, category archive, search).
To to this I’ve changed my entry.php from
<?php
if(is_archive() || is_search()){
get_template_part(‘entry’,’summary’);
} else {
get_template_part(‘entry’,’content’);
}
?>to:
<?php
if(is_archive() || is_search() || is_home()){
get_template_part(‘entry’,’summary’);
} else {
get_template_part(‘entry’,’content’);
}
?>That did the trick.
Problem is that the only link in excerpt that leads to full post is post title. I would like to make the whole excerpt as link to the post.
I have no knowledge of coding but thanks to Google i have found a way to set post thumbnail to lead to the post, so I’ve changed:
<div class=”entry-summary”>
<?php the_excerpt( sprintf(__( ‘continue reading %s’, ‘startup’ ), ‘<span class=”meta-nav”>»</span>’ ) ); ?>to following code:
<div class=”entry-summary”><?php if ( has_post_thumbnail()) : ?>
<a href=”<?php the_permalink(); ?>” title=”<?php the_title_attribute(); ?>” >
<?php the_post_thumbnail(); ?>
</a>
<?php endif; ?><?php the_excerpt( sprintf(__( ‘continue reading %s’, ‘startup’ ), ‘<span class=”meta-nav”>»</span>’ ) ); ?>Is there some better way for this to be done or can it be done at all?
Once again, I’ve made all the changes relying on Google, since my knowledge of code is equal to zero.
Thanks in advace!
December 30, 2012 at 11:42 AM #360Try simply wrapping it with a link like so:
<a href="<?php the_permalink(); ?>">
<?php
if(is_archive() || is_search() || is_home()){
get_template_part('entry','summary');
} else {
get_template_part('entry','content');
}
?>
</a>December 31, 2012 at 2:03 AM #372Unfortunately, it makes the entire excerpt as link and underlines it and after click leads to error.
Hope i will stumble upon some solution somewhere.
Thanks for your help!
December 31, 2012 at 11:46 AM #376It worked just fine in our testing.
For the underline, you could update this line:
<a href="<?php the_permalink(); ?>">
to:
<a href="<?php the_permalink(); ?>" style="text-decoration:none !important">
January 1, 2013 at 1:58 AM #381Great, finally it worked!
Probably messed up the code for a little when tried it for the first time.
Thank you for your help, you got your self a new customer!
January 1, 2013 at 12:27 PM #384Happy you got it working :).
- AuthorPosts
You must be logged in to reply to this topic.