# Plugin for embedding Discourse topics in wordpress pages or posts

**URL:** <https://meta.discourse.org/t/plugin-for-embedding-discourse-topics-in-wordpress-pages-or-posts/30228>\
**Category:** Plugin\
**Created:** [19 ביוני,‏ 2015,‏ 9:52pm UTC](https://meta.discourse.org/t/plugin-for-embedding-discourse-topics-in-wordpress-pages-or-posts/30228 "2015-06-19T21:52:24Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Matthieu](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/matthieu/32/107885_2.png) [@Matthieu](https://meta.discourse.org/u/Matthieu)\
**Post date:** [20 ביוני,‏ 2015,‏ 7:21am UTC](https://meta.discourse.org/t/plugin-for-embedding-discourse-topics-in-wordpress-pages-or-posts/30228/3 "2015-06-20T07:21:51Z")

</div>

It is quite easy, Discourse give a very complete json file with everything you need and a data structure well thought.

I get the first post like this `$parsed_json['post_stream']['posts'][0]['cooked'];`

But if you want to display all posts, it should be something like this

```php
$all_posts = $parsed_json['post_stream']['posts'];
foreach ($all_posts as $post) {
    echo $post['cooked'];
}

```

If you want reverse order:

```php
$all_posts = $parsed_json['post_stream']['posts'];
foreach (array_reverse($all_posts) as $post) {
    echo $post['cooked'];
}

```

If you want to play with it, you just need to change this file:  
[https://github.com/matthieu-lapeyre/wp-discourse-topic-integration/blob/master/includes/discourse-topic-integration-shortcode.php](https://github.com/matthieu-lapeyre/wp-discourse-topic-integration/blob/master/includes/discourse-topic-integration-shortcode.php)

I will give a try if I find some time

---

_[View the full topic](https://meta.discourse.org/t/plugin-for-embedding-discourse-topics-in-wordpress-pages-or-posts/30228)._
