Filtering the available categories for a custom post type

I’m having trouble getting WP Discourse Plugin Tips and Tricks to work in terms of restricting available categories for a custom post type.

Discourse plugin settings include the custom post type in question (as well as other post types) and a global default Discourse category has been selected. This global setting works: the specified category is the default and you can select to publish to a different Discourse category on a case by case basis.

For this specific custom post type, I wish to restrict publishing to a single, different category. We’d like this custom post type to automatically publish to Discourse, even if that means we need to force publish because we are using the block editor per this topic: WP Discourse now supports the WordPress Block Editor.


It looks like I forgot to add the wp_discourse_publish_categories to the category list that is displayed when the Block editor is being used. This will prevent that filter hook from being used when posts are published with the Block editor. I’m planning to push an updated version of the plugin to WordPress tomorrow. I’ll try to get the wp_discourse_publish_categories filter added to the Block editor in that update. If I run into any problems with that change, it may have to wait until Monday.


The issue with the wp_discourse_publish_categories filter has been fixed in WP Discourse version 2.0.6. That filter should now work correctly with either the Classic or the Block editor.

I also updated the code example here so that the example’s custom post type is configured in a way that will work with the Block Editor.


I can confirm that the Discourse Plugin update is now restricting the category for the custom post type as desired, thank you!


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.