# WP-Discourse \> 'Publish all new posts to Discourse.' \> not working

**URL:** https://meta.discourse.org/t/wp-discourse-publish-all-new-posts-to-discourse-not-working/58250
**Category:** WordPress
**Created:** [2017 年 3 月 2 日午後 7:48 UTC](https://meta.discourse.org/t/wp-discourse-publish-all-new-posts-to-discourse-not-working/58250 "2017-03-02T19:48:28Z")
**Posts on this page:** 1
**Showing post:** 13

<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: [2017 年 3 月 4 日午前 8:18 UTC](https://meta.discourse.org/t/wp-discourse-publish-all-new-posts-to-discourse-not-working/58250/13 "2017-03-04T08:18:53Z")

</div>

It’s actually fairly simple to get this working. I’ve added a `wpdc_publish_after_save` filter to the wp-discourse `publish_post_after_save` function that you can hook into. It’s passed the variables `$force_publish`, `$post_id`, and `$post`. It’s not yet merged into the main code, but you can get it here: [https://github.com/scossar/wp-discourse/tree/beta-after-save-filter](https://github.com/scossar/wp-discourse/tree/beta-after-save-filter).

Something like this added to your theme’s `functions.php` file will auto publish all posts from an array of feeds. There are some issues with the way images are being lightboxed on Discourse if they are passed a `srcset` attribute, and something should probably be done to get the author’s name to the top of the post.

```plaintext
add_filter( 'wpdc_publish_after_save', 'testeleven_publish_feed', 10, 3 );
// $post isn't used here, but it's available if you need it.
function testeleven_publish_feed( $force_publish, $post_id, $post ) {
    // The sources you want to publish from.
    $syndication_sources = array(
            'https://scossar.com',
    );
    $feed_uri = get_post_meta( $post_id, 'syndication_source_uri', true );

    if ( $feed_uri && in_array( $feed_uri, $syndication_sources, true) ) {
        // This isn't necessary, but it will cause the 'publish to Discourse' checkbox to be checked
        // if you edit the post later.
        add_post_meta( $post_id, 'publish_to_discourse', 1 );
        // Use for force the post to automatically publish to Discourse.
        $force_publish = true;
    }

    return $force_publish;
}

```

---

_[View the full topic](https://meta.discourse.org/t/wp-discourse-publish-all-new-posts-to-discourse-not-working/58250)._
