Plugin for embedding Discourse topics in wordpress pages or posts

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

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

If you want reverse order:

$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

I will give a try if I find some time

1 me gusta