在标签插入到数据库之前,有没有过滤器可以用来过滤标签?

时间:2011-06-07 作者:Can\'t Tell

我想在将标记插入数据库之前对其进行筛选。我知道pre_insert_term 滤器但我需要做的是一次查看所有标签。我需要限制每个帖子输入到数据库的标签数量。是否有过滤器来执行此操作?或者其他方法?

谢谢

2 个回复
SO网友:kaiser

一件好事是Action Reference.

你可以count 来自$post 上的数据pre_post_update.

SO网友:Chip Bennett

那么使用wp_set_post_tags() (Codex ref) 修改标记的数量,然后将其连接到save_postpublish_post 或任何适当的地方?

e、 g。

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\' );

结束

相关推荐

Tags as autocomplete values

如何将常规post标记作为自动完成字段的值加载?我现在得到的是这样的预设值:var data = {items: [ {value: \"1\", name: \"Siemens\"}, {value: \"2\", name: \"Phillips\"}, {value: \"3\", name: \"Whirlpool\"}, {value: \"4\", name: \"LG\"} }; $(\"#input_1_3\").autoSuggest(da