Jump to content

Blog Post Excerpt Glitch

Recommended Posts

Site URL: https://www.rendyreviews.com/movie-reviews

Hi I at the beginning of my posts I keep getting this glitch with my reviews whenever i post them.

1465255422_ScreenShot2021-06-16at11_15_23PM.thumb.jpg.e5bf73fa1e5891ccd28a99cde4ea9413.jpg.851275449317621c84cefe0cfbf92141.jpgThis is the code I'm working with:

 

<script>

document.addEventListener('DOMContentLoaded', function() {

    var element = document.querySelector('.BlogItem-title');

  if (!element) {

    return;

    }

    var newElement = document.createElement('h3');

    newElement.style.order = 1;

    newElement.className = "BlogItem-excerpt";

    newElement.innerHTML = document.querySelector('[property="og:description"]').getAttribute("content");

    var elementParent = element.parentNode;

 

    elementParent.insertBefore(newElement, element.nextSibling);

});

</script>

 

It works at times, it doubles up most of the time.

Can somebody help fix this for me? Thank you so much.

Link to comment
  • Replies 4
  • Views 274
  • Created
  • Last Reply

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.