# WP Discourse não publica postagem privada

**URL:** https://meta.discourse.org/t/wp-discourse-wont-publish-private-post/96166
**Category:** WordPress
**Created:** [1 Setembro , 2018 19:43 UTC](https://meta.discourse.org/t/wp-discourse-wont-publish-private-post/96166 "2018-09-01T19:43:37Z")
**Posts on this page:** 1
**Showing post:** 9

<div class="post-metadata">

### Author: ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)
#### Post date: [8 Setembro , 2018 01:14 UTC](https://meta.discourse.org/t/wp-discourse-wont-publish-private-post/96166/9 "2018-09-08T01:14:33Z")

</div>

I have added a `wpdc_publish_private_post` filter hook that you can use to publish private posts to Discourse. The filter passes up to two parameters to a function that you hook into it. The parameters are `$publish` (set to false) and `$post_id`, the WordPress post id.

If you wish to allow all private posts to be published to Discourse, you can add something like this to a plugin, or your theme’s `functions.php` file. You can name your hook functions however you choose, just be sure that the name is unique in your site’s codebase.

```plaintext
add_filter( 'wpdc_publish_private_post', 'wpdc_custom_publish_private_post', 10, 2 );
function wpdc_custom_publish_private_post( $publish, $post_id ) {
    if ( 'private' === get_post_status( $post_id ) ) {

        return true;
    }

    return false;
}

```

If you would only like to allow certain private posts to be published, you’ll need to do something like this:

```plaintext
add_filter( 'wpdc_publish_private_post', 'wpdc_custom_publish_private_post', 10, 2 );
function wpdc_custom_publish_private_post( $publish, $post_id ) {
    $post = get_post( $post_id );
    if ( /* Some condition that checks the $post object */ ) {
        
        return true;
    }
    
    return false;
}

```

One thing to note is that the ‘Show Full Post’ button on Discourse will not work for private WordPress posts - Discourse can’t retrieve the post’s content. You might want to disable this feature on Discourse by deselecting `embed truncate` in your Discourse settings.

---

_[View the full topic](https://meta.discourse.org/t/wp-discourse-wont-publish-private-post/96166)._
