WP Discourse sobre tema sem Editor de Site

I’ve been happy using the WP Discourse plugin for our podcast WordPress site to connect to our Discourse Community. I stopped seeing the Discourse discussions sometime ago after the latest plugin update.

I might be wrong but it looks like now the way to add it to a template is via Full site Editor (?). I might look to change but am very happy with my Anders Noren Garfunkle theme. It’s single post template has a layout that puts comments in a tabbed display at the bottom of the post, outside the range of widgets.

I did consider just manually adding a Discourse block to all posts, but for now have made an adjustment that inserts the Discourse discussions using the HTML code. In my child theme, I comment out the standard WordPress comments template (we only allow comments via Discord), and check the post meta data for a discourse ID.

<?php //comments_template( '', true ); ?>

<?php
	$discourse_topic_id = get_post_meta( $post->ID, 'discourse_topic_id', 1 ); ?>
	
	<?php if ($discourse_topic_id) : ?>
	
		<div id="discourse-comments"></div>

			<script type="text/javascript">
			  DiscourseEmbed = { discourseUrl: 'https://connect.oeglobal.org/',
								 topicId: '<?php echo $discourse_topic_id?>' };
			
			  (function() {
				var d = document.createElement('script'); d.type = 'text/javascript'; d.async = true;
				d.src = DiscourseEmbed.discourseUrl + 'javascripts/embed.js';
				(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(d);
			  })();
			</script>
	
<?php endif; ?>

It’s not as fancy a layout but works for now – see bottom of newest episode for example.