# Wordpress posts published to Discourse include HTML?

**URL:** https://meta.discourse.org/t/wordpress-posts-published-to-discourse-include-html/246439
**Category:** WordPress
**Created:** [November 22, 2022, 4:47pm UTC](https://meta.discourse.org/t/wordpress-posts-published-to-discourse-include-html/246439 "2022-11-22T16:47:56Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![vanclute](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vanclute/32/282155_2.png) [@vanclute](https://meta.discourse.org/u/vanclute)
#### Post date: [November 22, 2022, 4:47pm UTC](https://meta.discourse.org/t/wordpress-posts-published-to-discourse-include-html/246439/1 "2022-11-22T16:47:56Z")

</div>

I just tried my first manual push of a WP post into a Discourse topic. It worked, but ended up adding HTML that makes the post not look great, and I don’t like that HTML I didn’t specify is being added to my content. Here’s what it posted:

```plaintext
<small>Originally published at: https://original/post/url/
        </small><br>Here&#8217;s the excerpt . It&#8217;s valid&hellip;

```

So it’s adding some formatting tags as well as HTML entities I guess. Not preferable at all… is there a way to prevent this? I just want it to post the exact excerpt content straight from WP, with a clean link back to the original post.

---

<div class="post-metadata">

### Author: ![angus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/angus/32/341715_2.png) [@angus](https://meta.discourse.org/u/angus)
#### Post date: [November 23, 2022, 8:56am UTC](https://meta.discourse.org/t/wordpress-posts-published-to-discourse-include-html/246439/2 "2022-11-23T08:56:40Z")

</div>

Hey @vanclute,

Discourse is designed to handle HTML in the raw content of the posts. Unless you’re seeing HTML entities in the published version (i.e. what appears in the topic when you’re reading it) this is how it’s meant to work, and does work successfully for many Wordpress / Discourse combinations.

You can customise the HTML that is published to Discourse using the tips described here

> [@Customize the structure of WP Discourse templates](https://meta.discourse.org/t/customize-the-structure-of-wp-discourse-templates/50754):
>
> The [WP Discourse](https://github.com/discourse/wp-discourse) plugin uses HTML templates to add markup to Discourse comments for publishing on WordPress and to WordPress posts for publishing on Discourse. The text content of these templates can be customized on the plugin’s options page. To change the structure of a templates requires you to add a function to your theme’s functions.php file This #howto will explain how to do that. The templates In the plugin’s code, the templates are static functions that return a mixture of html and templ…

The reason it is HTML rather than markdown is explained further here

> [@Wordpress plugin and html-as-text (especially for mail)](https://meta.discourse.org/t/wordpress-plugin-and-html-as-text-especially-for-mail/240502/8):
>
> Ok, I’m going to respond to the issues you’re raising here separately. I understand why you’re connecting them, but hopefully you’ll see why they’re separate issues. HTML entites in plain text email notifications the nicest thing would be for the email messages to be multi-part with a clean-text rendered markdown text/plain and a separate text/html This is actually how Discourse email notifications currently work. If you look at the “original” of a Discourse email notification you’ll see the…

---

<div class="post-metadata">

### Author: ![Jagster](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jagster/32/192154_2.png) [@Jagster](https://meta.discourse.org/u/Jagster)
#### Post date: [November 23, 2022, 10:42am UTC](https://meta.discourse.org/t/wordpress-posts-published-to-discourse-include-html/246439/3 "2022-11-23T10:42:41Z")

</div>

I’m drifting toward off topic here, but HTML is not an issue IMO. But short codes are if a wordpress-post is shown as text on Discourse, because those are stripped off.

I kind of could imagine why this is happening and that’s why I can’t count it as a bug or similar, it is just another limitation.

But I haven’t had any issues with HTML per se. But WordPress itself, depending of theme I guess, will strip off html from excerps quite often, though.

---

<div class="post-metadata">

### Author: ![vanclute](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vanclute/32/282155_2.png) [@vanclute](https://meta.discourse.org/u/vanclute)
#### Post date: [November 24, 2022, 10:55pm UTC](https://meta.discourse.org/t/wordpress-posts-published-to-discourse-include-html/246439/4 "2022-11-24T22:55:27Z")

</div>

Thanks for the feedback on this. I don’t want to go editing WP files, but there is definitely one serious problem with the way links are pushed from WP to Discourse.

If I paste a link into a topic manually in Discourse, it expands into something pretty, like this:

> **[Wikipedia

The Free Encyclopedia](https://www.wikipedia.org/)**
>
> You deserve an explanation, so please don't skip this 1-minute read. Our fundraiser won't last long, and we need some help to reach our goal. Less than 2% of our readers donate, but if everyone who saw this message gave $2.75, we'd hit our goal in a few hours. The rare few who donate do so because Wikipedia provides them with useful knowledge. If that sounds like you, please donate $2.75. Any contribution you make today helps. We ask you, sincerely: don't skip this. Be one of the rare readers who...

If however I push a link from WP, the Discourse post appears as this:

Originally published at: [www.wikipedia.com](http://www.wikipedia.com)

The html “small” tags are breaking the pretty preview on everything that’s pushed into Discourse from WP. ☹

---

<div class="post-metadata">

### Author: ![vanclute](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vanclute/32/282155_2.png) [@vanclute](https://meta.discourse.org/u/vanclute)
#### Post date: [November 24, 2022, 11:29pm UTC](https://meta.discourse.org/t/wordpress-posts-published-to-discourse-include-html/246439/5 "2022-11-24T23:29:56Z")

</div>

I stand corrected, it’s not the small tags, it’s that the link is not on a line of its own. If I edit the resulting Discourse post just to insert a newline at the URL, then it expands into the “pretty” formatting.

---

<div class="post-metadata">

### Author: ![angus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/angus/32/341715_2.png) [@angus](https://meta.discourse.org/u/angus)
#### Post date: [November 25, 2022, 8:09am UTC](https://meta.discourse.org/t/wordpress-posts-published-to-discourse-include-html/246439/6 "2022-11-25T08:09:04Z")

</div>

Hey @vanclute

> [@vanclute](#):
>
> I don’t want to go editing WP files

You don’t need to. As @Jagster pointed out on your other topic

> [@Possible to publish from Wordpress only a specified category?](https://meta.discourse.org/t/possible-to-publish-from-wordpress-only-a-specified-category/246437/4):
>
> Install Code Snippet or similar and do that through it

> **[Code Snippets](https://wordpress.org/plugins/code-snippets/)**
>
> An easy, clean and simple way to enhance your site with code snippets.

This is how Wordpress is designed to be used. It’s an open source platform that supports a decent chunk of the sites on the web. This diversity means that the off the shelf settings are never going to satisfy everyone.

> [@vanclute](#):
>
> The html “small” tags are breaking the pretty preview on everything that’s pushed into Discourse from WP. ☹

Please read the topic I linked. You can change that to your liking using the methods described there

> [@Customize the structure of WP Discourse templates](https://meta.discourse.org/t/customize-the-structure-of-wp-discourse-templates/50754#add-the-featured_image-to-the-publish-template-7):
>
> The [WP Discourse](https://github.com/discourse/wp-discourse) plugin uses HTML templates to add markup to Discourse comments for publishing on WordPress and to WordPress posts for publishing on Discourse. The text content of these templates can be customized on the plugin’s options page. To change the structure of a templates requires you to add a function to your theme’s functions.php file This #howto will explain how to do that. The templates In the plugin’s code, the templates are static functions that return a mixture of html and templ…

If you get stuck with that just respond to that topic and I’ll help you 🙂

---

<div class="post-metadata">

### Author: ![vanclute](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vanclute/32/282155_2.png) [@vanclute](https://meta.discourse.org/u/vanclute)
#### Post date: [November 25, 2022, 4:09pm UTC](https://meta.discourse.org/t/wordpress-posts-published-to-discourse-include-html/246439/7 "2022-11-25T16:09:49Z")

</div>

The issue was not the small html tags however, it was not having a line break before the URL. And from what I read I would be required to go editing files which I don’t want to get into, and I don’t want to muck about in PHP via a plugin either. At this time I just edit the post and add a line break before the URL each time I publish a post. It’s slightly annoying but not a huge headache. Would of course be better to not have this issue be an issue in the first place but, is what it is.
