# Utiliza WP Discourse para publicar publicaciones de WordPress a Discourse

**URL:** <https://meta.discourse.org/t/use-wp-discourse-to-publish-posts-from-wordpress-to-discourse/223492>\
**Category:** Administrators\
**Tags:** wordpress, video, how-to\
**Created:** [6 Abril, 2022 13:01 UTC](https://meta.discourse.org/t/use-wp-discourse-to-publish-posts-from-wordpress-to-discourse/223492 "2022-04-06T13:01:40Z")\
**Posts on this page:** 1\
**Showing post:** 19

<div class="post-metadata">

**Author:** ![carbonrich](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/carbonrich/32/274219_2.png) [@carbonrich](https://meta.discourse.org/u/carbonrich)\
**Post date:** [6 Octubre, 2022 17:28 UTC](https://meta.discourse.org/t/use-wp-discourse-to-publish-posts-from-wordpress-to-discourse/223492/19 "2022-10-06T17:28:28Z")

</div>

Estoy intentando establecer diferentes categorías para diferentes `custom_post_types`. El código a continuación selecciona la categoría correcta en el administrador de WordPress. Sin embargo, al publicar en Discourse, la categoría no se establece allí (y se establece por defecto en “sin categorizar”)…

¿Quizás me estoy perdiendo algo obvio?

```plaintext
// WP Discourse establece categorías de foro CPT para CPTS
 
add_filter( 'wp_discourse_publish_categories', 'radhr_filter_categories_policies', 10, 2 );
function radhr_filter_categories( $categories, $post ) {
	if ( 'policy' === get_post_type( $post ) ) {
		$output = [];
		foreach ( $categories as $category ) {
			if ( 'Policies' === $category['name']) {
				$output[] = $category;
			}
		}
		return $output;
	} 
	
	elseif ( 'guide' === get_post_type( $post ) ) {
		$output = [];
		foreach ( $categories as $category ) {
			if ( 'Guides' === $category['name']) {
				$output[] = $category;
			}
		}
		return $output;
	}
	
	elseif ( 'post' === get_post_type( $post ) ) {
		$output = [];
		foreach ( $categories as $category ) {
			if ( 'Blogs' === $category['name']) {
				$output[] = $category;
			}
		}
		return $output;
	}

	return $categories;
}

```

---

_[View the full topic](https://meta.discourse.org/t/use-wp-discourse-to-publish-posts-from-wordpress-to-discourse/223492)._
