Add button link after each excerpt
Hello,
I need to add a button link to post after each excerpt, this is the html example:
- <div class="post-content">
- <h2><a href="https://link1">link text1</a></h2>
- <div class="excerpt"><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer faucibus risus vel risus aliquet commodo. Nullam luctus blandit erat, non pellentesque felis tincidunt eget. [...]</p></div>
- </div>
- <div class="post-content">
- <h2><a href="https://link2">link text2</a></h2>
- <div class="excerpt"><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer faucibus risus vel risus aliquet commodo. Nullam luctus blandit erat, non pellentesque felis tincidunt eget. [...]</p></div>
- </div>
and this is the jQuery I am using:
- jQuery(document).ready(function() {
- jQuery('.post content a').each(function ()
- {
- var value = jQuery(this).attr('href');
- jQuery('.excerpt').append("<a class='button' target='_self' href='" + jQuery(this).attr("href") + "'><span class='button-text'>Learn More...</span></a>");
- });
- });
But if I have 4 posts I get the 4 button link after each post excerpt. Can you help me?
Thanks