# 如何在没有自动发布的情况下启用帖子类型的可发布性

**URL:** <https://meta.discourse.org/t/hot-to-enable-publishability-for-a-post-type-without-auto-publish/358495>\
**Category:** WordPress\
**Created:** [2025 年3 月 23 日 13:15 UTC](https://meta.discourse.org/t/hot-to-enable-publishability-for-a-post-type-without-auto-publish/358495 "2025-03-23T13:15:55Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

作者： ![Firsh](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/firsh/32/454861_2.png) [@Firsh](https://meta.discourse.org/u/Firsh)\
发布日期： [2025 年3 月 23 日 23:00 UTC](https://meta.discourse.org/t/hot-to-enable-publishability-for-a-post-type-without-auto-publish/358495/4 "2025-03-23T23:00:01Z")

</div>

是的，过滤器是关键！我将此作为类的一部分，并且似乎运行正常：

```plaintext
add_filter('wpdc_publish_after_save', [$this, 'prevent_autopublish_for_konyv'], 10, 3);

public function prevent_autopublish_for_konyv($publish_to_discourse, $post_id, $post)
	{
		if ('konyv' === get_post_type($post)) {
			return false; // Prevent auto-publishing for 'konyv' post type
		}
		return $publish_to_discourse; // Allow normal behavior for other post types
	}

```

---

_[View the full topic](https://meta.discourse.org/t/hot-to-enable-publishability-for-a-post-type-without-auto-publish/358495)._
