# בחר אוטומטית קטגוריית נושא על סמך קטגוריית הפוסט?

**URL:** <https://meta.discourse.org/t/automatically-select-topic-category-based-on-post-category/229058>\
**Category:** WordPress\
**Created:** [5 ביוני,‏ 2022,‏ 11:12am UTC](https://meta.discourse.org/t/automatically-select-topic-category-based-on-post-category/229058 "2022-06-05T11:12:35Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![oopsyscoops](https://avatars.discourse-cdn.com/v4/letter/o/f14d63/32.png) [@oopsyscoops](https://meta.discourse.org/u/oopsyscoops)\
**Post date:** [7 ביוני,‏ 2022,‏ 12:23pm UTC](https://meta.discourse.org/t/automatically-select-topic-category-based-on-post-category/229058/3 "2022-06-07T12:23:06Z")

</div>

Thanks!

> You can do this with the `wpdc_change_post_category` filter. It’d be something like (untested example code, but may work out of the box):

I believe you mean `wpdc_publish_post_category`? `wpdc_change_post_category` doesn’t appear to actually exist. It’s just a custom function name that can be anything, correct?

`$wp_category_name = get_the_category( $post_id )[0]->name` is missing the closing `;`.

After that, I get a **too few arguments** error concerning `function wpdc_change_post_category( $category, $post_id ) {`. It might be because `$category` is undefined? I may test more later.

Concerning adding this as an official feature, I don’t think it would be that big of a can of worms, considering two options:

1. The **Force Category Update** option already exists. This could be extended to a feature that forces Discourse/WordPress categories to always be in sync.

or

1. Maybe they don’t need to be in sync at all, but rather if a category doesn’t exist in Discourse, it simply creates it.

---

_[View the full topic](https://meta.discourse.org/t/automatically-select-topic-category-based-on-post-category/229058)._
