# WordPress Hook to Change Default Publishing Discourse Category per Post Type

**URL:** <https://meta.discourse.org/t/wordpress-hook-to-change-default-publishing-discourse-category-per-post-type/252383>\
**Category:** WordPress\
**Created:** [January 20, 2023, 5:06am UTC](https://meta.discourse.org/t/wordpress-hook-to-change-default-publishing-discourse-category-per-post-type/252383 "2023-01-20T05:06:29Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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:** [January 20, 2023, 6:12am UTC](https://meta.discourse.org/t/wordpress-hook-to-change-default-publishing-discourse-category-per-post-type/252383/2 "2023-01-20T06:12:41Z")

</div>

> [@TEKFused](#):
>
> I’d like to change the “Default Discourse Category” dependent on the post’s post type. Is there a WordPress hook I can use to accomplish this?

There is a `wp_discourse_publish_categories` filter hook that I think will work for this. Some details about it are here: [WP Discourse plugin tips and tricks](https://meta.discourse.org/t/wp-discourse-plugin-tips-and-tricks/50757#filtering-the-available-categories-for-a-custom-post-type). In the example code, I set it so that two categories were available for a custom post type. I think for your case all you will need to do is just make a single category available per custom post type. You will need to test this out.

> [@TEKFused](#):
>
> I’d also like to be able to post to subcategories if that matters in the code.

As long as the “Display Subcategories” option is enabled, you will be able to use subcategories. That option is found on the [WP Discourse](https://github.com/discourse/wp-discourse) plugin’s Publishing Settings tab.

---

_[View the full topic](https://meta.discourse.org/t/wordpress-hook-to-change-default-publishing-discourse-category-per-post-type/252383)._
