WordPress Hook to Change Default Publishing Discourse Category per Post Type


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?

So basically, if a post is post type a, it would post to category 1, and if a post is post type b, it would post to category 2.

I’d also like to be able to post to subcategories if that matters in the code.

Thank you very much!


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. 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.

As long as the “Display Subcategories” option is enabled, you will be able to use subcategories. That option is found on the WP Discourse plugin’s Publishing Settings tab.


Thanks very much! I’ll take a look and will let you know if I bump into any issues.