Support » Plugin: Contextual Related Posts » Add button “Read more…”

  • Resolved adv_user

    (@adv_user)


    Hi. Congratulations on the fantastic plugin!
    I would just like to include a “read more” button because I chose to display the thumbnail excerpt, and you can only click on the image / title. Many users get confused and try to click on the excerpt.

    Is it possible to put link in the excerpt and / or add the read more button in the end?
    Thank you.

    My HTML code (output):

    
    <h2>Related posts:</h2>
    <div class="crp_related crp_related_shortcode ">
    <ul>
    <li><a href="#link_site"    target="_blank" ><img src="1822414_960_720-150x150.jpg" alt="#title" title="#title" width="150" height="150" class="crp_thumb crp_featured" /><span class="crp_title">#title</span></a>
    <span class="crp_excerpt">#excerpt &hellip;</span>
    </li>
    </ul>
    <div class="crp_clear"></div>
    </div>
    

    I need:
    <a href="#link..."><span class="crp_excerpt">#excerpt &hellip;</span></a>

    And/or

    <span class="crp_excerpt">#excerpt &hellip;</span>
    <a href="#link..."><span class="btn">Read more&hellip;</span></a>

    Without losing changes, in future updates of the plugin.

    Thank you!

    • This topic was modified 1 year, 1 month ago by adv_user.
    • This topic was modified 1 year, 1 month ago by adv_user.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Ajay

    (@ajay)

    You could potentially add a filter function to crp_excerpt which will allow you to add your own read more link.

    https://github.com/WebberZone/contextual-related-posts/blob/master/includes/tools.php#L64

    Hello. Thanks for the answer.
    I was able to add the text “read more…”, but the link does not appear in the description, nor the button.
    Do you have an example of how I could achieve this result?
    Thank you again.

    Plugin Author Ajay

    (@ajay)

    Can you post the code you’re my currently? The filter also passes the ID of the post as the second parameter so you can use that with get_the_permalink( $id) to get the link, if I’m not mistaken

    I only need a exemple: how to use the crp_excerpt function?

    I need:
    <a href="#link..."><span class="crp_excerpt">#excerpt &hellip;</span></a>

    And
    <a href="#link..."><span class="btn">Read more&hellip;</span></a>

    Thanks.

    Hi.
    Is it not possible to do this in a simple way?
    Thank you again.

    Plugin Author Ajay

    (@ajay)

    You can use the filter function like this. Please double-check formatting, closing brackets, etc.

    
    function crp_change_excerpt( $output, $id ) {
    
    $this_post = get_post( $id );
    
    $output .= '<a href="' . get_the_permalink( $this_post ) . '"><span class="crp_excerpt">#excerpt &hellip;</span></a>';
    
    $output .= '<a href="' . get_the_permalink( $this_post ) . '"><span class="btn">Read more&hellip;</span></a>';
    
    }
    add_filter( 'crp_excerpt', 'crp_change_excerpt', 10, 2 );
    
    • This reply was modified 1 year, 1 month ago by Ajay.
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Add button “Read more…”’ is closed to new replies.