# 如何在 WordPress 插件中传递自定义字段类型和分类法？

**URL:** <https://meta.discourse.org/t/how-to-pass-custom-field-types-and-taxonomies-to-the-wordpress-plugin/77817>\
**Category:** WordPress\
**Created:** [2018 年1 月 12 日 08:41 UTC](https://meta.discourse.org/t/how-to-pass-custom-field-types-and-taxonomies-to-the-wordpress-plugin/77817 "2018-01-12T08:41:29Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

作者： ![icaria36](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/icaria36/32/426431_2.png) [@icaria36](https://meta.discourse.org/u/icaria36)\
发布日期： [2018 年2 月 3 日 23:58 UTC](https://meta.discourse.org/t/how-to-pass-custom-field-types-and-taxonomies-to-the-wordpress-plugin/77817/3 "2018-02-03T23:58:35Z")

</div>

Thank you for your reply. I finally started working on this, adding the function above to my theme’s functions.php. I can add the `{featuredimage}` just fine, proving that the function itself works. See

[https://la.confederac.io/t/definamos-nuestras-propias-agendas-al-margen-de-los-medios-de-comunicacion-de-masas/1360](https://la.confederac.io/t/definamos-nuestras-propias-agendas-al-margen-de-los-medios-de-comunicacion-de-masas/1360)

However, I am failing at adding my own custom fields. You can see the proof of my failure by the `my_tipos($id)` string printed below the featured image. I tried many combinations, and I would either get the strings printed or `HTTP ERROR 500` when posting an update to the Discourse topic from the WP post.

```plaintext
// Get the custom fields and taxonomies that you want published from your post

```

How is this done? Could you provide an example, please? For what is worth, this is how that custom field is rendered in the post template:

```plaintext
       $id = get_the_ID();
       $type_of_action = my_tipos($id);
(...)
       <span class="conf-action-type"><?php echo $type_of_action; ?></span>

```

The result in this case would be “CULTURA - PERIODISMO - EMANCIPACIÓN” – see [the WordPress page](https://confederac.io/acciones/definamos-nuestras-propias-agendas-al-margen-de-los-medios-de-comunicacion-de-masas).

---

_[View the full topic](https://meta.discourse.org/t/how-to-pass-custom-field-types-and-taxonomies-to-the-wordpress-plugin/77817)._
