Skip to content

Commit

Permalink
add disqus_thread id to comment section for block themes for loading …
Browse files Browse the repository at this point in the history
…embed. also add error message if no disqus_thread id is found on the page.
  • Loading branch information
Debian committed Feb 15, 2024
1 parent f4d70c5 commit f98985e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions disqus/public/js/comment_embed.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,18 @@ var disqus_config = function () {
};

(function() {
// Adds the disqus_thread id to the comment section if site is using a WP block theme
var commentsBlock = document.querySelector('.wp-block-comments');
if (commentsBlock) {
commentsBlock.id = 'disqus_thread';
}
if (document.getElementById(disqus_container_id)) {
var dsq = document.createElement('script');
dsq.type = 'text/javascript';
dsq.async = true;
dsq.src = 'https://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
} else {
console.error("Could not find 'disqus_thread' container to load DISQUS. This is usually the result of a WordPress theme conflicting with the DISQUS plugin. Try switching your site to a Classic Theme, or contact DISQUS support for help.");
}
})();

0 comments on commit f98985e

Please sign in to comment.