Add discourse category link to wordpress


With the plugin Wp Discourse is there a possibility to add discourse category preview on Wordpress.
I think Rss integrator will work for this but with the WP Discourse plugin is it possible ?
a bit like on this page :



Unfortunately from what I can see, there’s no option for that. But you can do it by following these steps:

  1. Install the discourse shortcode plugin and use the schortcode in your text sidebar widget [discourse_topics]

  2. Browse to wp-discourse-shortcodes-master / lib / discourse-topic-formatter.php search for this line
    $category = $this->find_discourse_category( $topic );

  3. After that line, paste this:
    $category_url = $this->discourse_url . "/c/{$category['slug']}/{$category['id']}";

  4. Search for this ( you’ll find two lines, for top and bottom positions ):
    $output .= '<span class="wpds-shortcode-category">' . $this->discourse_category_badge( $category ) . '</span>';

  5. Replace them with:
    $output .= '<span class="wpds-shortcode-category"><a class="wps-cat-link" target="_blank" href="' . esc_url( $category_url ) . '">' . $this->discourse_category_badge( $category ) . '</a></span>';

  6. Go to your wp dashboard and check this box and click Save options

Keep in mind that this will be overwritten when you’ll update the wp-discourse-shortcodes plugin, so you might wanna make a backup before updating. Good luck.

What you are suggesting may work, but I would not recommend anyone edit plugins in this way unless they are fully aware of what they are doing. Otherwise you could easily break your WordPress site. A PR to add a discourse_categories shortcode to the WP Discourse shortcodes plugin is something that might be accepted though.

1 Like

It works on our website (hovered link):

But yeah I agree, is not the best way.

1 Like