WordPressからDiscourseに公開された投稿をタグ付けしてください

Posts can now be tagged when they are published with the WP Discourse plugin. To tag a post, click on the Discourse meta box Advanced Options link to expand the meta box. Add tags to the Tag input, either one at a time, or as a comma separated list.

Any spaces in tag names will be converted to hyphens. The maximum number of tags is set by the ‘Maximum Number of Tags’ option found on the Publishing Settings tab. The maximum number of tags will default to 5 if the setting is left empty. Tags that are not allowed on Discourse due to Site Setting or category restrictions will be omitted when the post is published to Discourse.

「いいね!」 7

Is there a way to hook into this to prepopulate specific custom post types with specific tags?

「いいね!」 1

The WP DIscourse plugin doesn’t have a hook that can be used to automatically add tags to a post before it gets published to Discourse. I’ll add a hook for that can be used for this and let you know when that has been done.

「いいね!」 4

古い投稿をぶつけて申し訳ありませんが、これは追加されましたか?ソースコードを調べようとしましたが、何も見つかりませんでした。

「いいね!」 2

まだそのフックを追加していません。次のリリースに追加します :+1:

「いいね!」 2

もう2年も経ったんですね :open_mouth: とっくに実装されているべきでしたね :laughing:

いや、冗談です。よろしくお願いします :slight_smile: :+1:

「いいね!」 1

ねえ、新しいリリースが作成されたようですが、これは追加されましたか?

いいえ、そのリリースは別の特定の懸念事項に関するものでした。次回のリリースに含めるようにします。

これを実現するには、wpc_publish_body フィルターを使用できます。例:

add_filter(  'wpdc_publish_body', function( $body, $remote_post_type, $post_id ) {
   if ( 'create_post' === $remote_post_type ) {
      $body['tags'] = array( 'tag1', 'tag2' );
   }
   return $body;
}, 10, 3);

2.4.5 では、特定のタイプの投稿にタグを追加する具体的なケースを容易にするために、post_id がフィルターのパラメーターとして追加されました。

「いいね!」 2