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

**URL:** <https://meta.discourse.org/t/how-to-pass-custom-field-types-and-taxonomies-to-the-wordpress-plugin/77817>\
**Category:** WordPress\
**Created:** [2018年一月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:** 2

<div class="post-metadata">

**Author:** ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)\
**Post date:** [2018年一月12日 21:21 UTC](https://meta.discourse.org/t/how-to-pass-custom-field-types-and-taxonomies-to-the-wordpress-plugin/77817/2 "2018-01-12T21:21:10Z")

</div>

> [@icaria36](#):
>
> is any way to make the plugin post selected custom fields and custom taxonomies as well?

Yes. You can customize the `discourse_publish_format_html` template for a specific post type. See this topic for more details about customizing the templates: [Customize the structure of WP Discourse templates](https://meta.discourse.org/t/wp-discourse-template-customization/50754)

Something like this, added to a plugin, or to your theme’s `functions.php` file should work. You can use the following tags in the template: `{excerpt}, {blogurl}, {author}, {thumbnail}, {featuredimage}`

```php

add_filter( 'discourse_publish_format_html', 'wpdc_custom_discourse_publish_format_html' );
function wpdc_custom_discourse_publish_format_html( $output ) {
    global $post;
    if ( 'your_custom_type' === $post->post_type ) {
        // Get the custom fields and taxonomies that you want published from your post, then...
	    ob_start();
	    ?>
        Originally published at: {blogurl}<br><br>
        {excerpt}

	    <?php
	    $output = ob_get_clean();
    }

    return $output;
}

```

---

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