データベースに挿入される前にタグをフィルタリングしたいです。私は pre_insert_term フィルタを知っています。しかし、私がする必要があるのは一度にすべてのタグを見ることです。 1回の投稿でデータベースに入力されるタグの数を制限する必要があります。これを行うためのフィルタはありますか?それとも他の方法?
ありがとう
タグの数を変更するためにwp_set_post_tags()
( Codex ref )を使用して、それをsave_post
またはpublish_post
、あるいは必要に応じてどこにでもフックすることについてはどうでしょうか。
例えば.
function mytheme_limit_post_tags( $post_id ) {
// code to count/limit the number of tags
// then pass the modified list of tags to wp_set_post_tags
wp_set_post_tags( $post_id, $tags, false );
}
add_action( 'publish_post', 'mytheme_limit_post_tags' );
良いことに - いつものように - は アクションリファレンス です。
$post
上のpre_post_update
データからの用語をcount
にすることができます。