# ¿Es posible publicar desde Wordpress solo una categoría especificada?

**URL:** <https://meta.discourse.org/t/possible-to-publish-from-wordpress-only-a-specified-category/246437>\
**Category:** WordPress\
**Created:** [22 Noviembre, 2022 16:43 UTC](https://meta.discourse.org/t/possible-to-publish-from-wordpress-only-a-specified-category/246437 "2022-11-22T16:43:20Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![angus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/angus/32/341715_2.png) [@angus](https://meta.discourse.org/u/angus)\
**Post date:** [22 Noviembre, 2022 17:22 UTC](https://meta.discourse.org/t/possible-to-publish-from-wordpress-only-a-specified-category/246437/2 "2022-11-22T17:22:27Z")

</div>

Hola @vanclute,

Puedes usar el filtro `wpdc_publish_after_save` para lograr esto. En el archivo `functions.php` de tu WordPress, añade lo siguiente:

```php
function publish_to_discourse( $force_publish, $post_id, $post ) {
  return has_term( TERM, TAXONOMY, $post );
}
add_filter( 'wpdc_publish_after_save', 'publish_to_discourse', 10, 3 );

```

Necesitarás reemplazar TERM y TAXONOMY con lo que estés usando para las “categorías” en WordPress. Ten en cuenta que TERM puede ser un array, por ejemplo:

```php
array( 'nombre de categoría 1', 'nombre de categoría 2')

```

### Ejemplo

```php
function publish_to_discourse( $force_publish, $post_id, $post ) {
  return has_term( array( 'news', 'blog' ), 'category', $post );
}
add_filter( 'wpdc_publish_after_save', 'publish_to_discourse', 10, 3 );

```

---

_[View the full topic](https://meta.discourse.org/t/possible-to-publish-from-wordpress-only-a-specified-category/246437)._
