# 混合了 WordPress 博客评论、公开和隐藏的 Discourse 线程？

**URL:** <https://meta.discourse.org/t/mix-of-wordpress-blog-comments-public-and-hidden-discourse-threads/87869>\
**Category:** WordPress\
**Created:** [2018 年5 月 19 日 04:24 UTC](https://meta.discourse.org/t/mix-of-wordpress-blog-comments-public-and-hidden-discourse-threads/87869 "2018-05-19T04:24:32Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

作者： ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)\
发布日期： [2018 年5 月 19 日 17:31 UTC](https://meta.discourse.org/t/mix-of-wordpress-blog-comments-public-and-hidden-discourse-threads/87869/2 "2018-05-19T17:31:52Z")

</div>

> [@Tjeef](#):
>
> I have also seen a comment somewhere that the WP-Discourse plugin could not handle a “private forum”.

Yes, this can be done. As long as you have set an admin API key on the [WP Discourse](https://github.com/discourse/wp-discourse)/Connection settings tab, comments from a private forum, or a private category on a public forum, can be displayed on WordPress.

> [@Tjeef](#):
>
> The neatest looking would be if the outsiders only see the comments in WP and not the forum thread.

_I’m not sure that this answers your question, but it might give you some ideas. I need to write some documentation for what can be done with the Link to Existing Topic functionality. This is a good starting point._

One way to approach this would be to link a WordPress post with an existing Discourse topic. To do this, first, enable the ‘Use Discourse Comments’ setting on [WP Discourse](https://github.com/discourse/wp-discourse) (found in the [WP Discourse](https://github.com/discourse/wp-discourse) Commenting settings tab.) Then create a post on WordPress that you would like to associate with an existing Discourse topic. In the Discourse meta box for that post, select Link to Existing Topic and enter the URL of the Discourse topic:

 ![30%20AM](https://global.discourse-cdn.com/meta/original/3X/e/6/e6263fd03ff172a614843d05f8b43354bbfa3e9a.png)

Click the Publish button, or the Update button if the post has already been published on WordPress. That will link the posts and allow Discourse comments to be pulled across to WordPress. Unless you want to overwrite the Discourse topic with the WordPress post, don’t ever select the Update Discourse Topic checkbox (I will add a warning to this checkbox.)

You can unlink the post from Discourse at any time by selecting the Unlink Post from Discourse checkbox. You can unlink a post from Discourse and then relink it to a different Discourse topic if you like.

 ![24%20AM](https://global.discourse-cdn.com/meta/original/3X/0/3/03d674c123578abfba15bf15ed0f1dafedf5f5e1.png)

The [WP Discourse](https://github.com/discourse/wp-discourse) plugin displays a Join Discussion link at the bottom of the Discourse comments. If you don’t want WordPress users to be able to click through to the Discourse topic, you will need to customize the `discourse_no_replies_html` and `discourse_replies_html` templates to remove the link to the Discourse comments. Something like this, added either to your theme’s `functions.php` file or a plugin would work:

```plaintext
add_filter( 'discourse_no_replies_html', 'wpdc_custom_no_replies_html' );
function wpdc_custom_no_replies_html() {

    return "";
}

add_filter( 'discourse_replies_html', 'wpdc_custom_discourse_replies_html' );
function wpdc_custom_discourse_replies_html() {
    ob_start();
    ?>
    <div id="comments" class="comments-area discourse-comments-area">
        <h2 class="comments-title discourse-comments-title">Notable Replies</h2>
        <ol class="comment-list">{comments}</ol>
        <div class="respond comment-respond">
            <p class="more-replies">{more_replies}</p>
            <div class="comment-reply-title">
                <h4 class="discourse-participants">Participants</h4>
                <p>{participants}</p>
            </div>
        </div>
    </div>
    <?php
    
    return ob_get_clean();
}

```

That will give you a result like this on WordPress. Ignore the styling on this screenshot, it’s from my development site:

 ![25%20AM](https://global.discourse-cdn.com/meta/original/3X/1/8/181d8ef1e2a1ded60c326be1a2d088455ab59187.png)

What might work better for your use case would be to have `discourse_topic` and `discourse_post` shortcodes that you could embed in a WordPress post. You could then associate the WordPress post with a public Discourse topic while having comments from a private topic Displayed within, or at the bottom of, the WordPress post. The ‘Join Discussion’ link for the post would link to the public topic. Shortcodes for doing this are not yet available in the [WP Discourse](https://github.com/discourse/wp-discourse) plugin.

Let me know if any of this isn’t clear, or if I’m misunderstanding what you are trying to do.

---

_[View the full topic](https://meta.discourse.org/t/mix-of-wordpress-blog-comments-public-and-hidden-discourse-threads/87869)._
