New Topic

Make the_excerpt() clickable

Home › Forum › Customization › Make the_excerpt() clickable

This topic contains 5 replies, has 2 voices, and was last updated by  StartupWP 3 years, 8 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #357

    skoosha
    Member

    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”>&raquo;</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”>&raquo;</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!

     

    #360

    StartupWP
    Support

    Try 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>

    #372

    skoosha
    Member

    Unfortunately, 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!

    #376

    StartupWP
    Support

    It 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">

    #381

    skoosha
    Member

    Great, 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!

    #384

    StartupWP
    Support

    Happy you got it working :).

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.