admin管理员组文章数量:1130349
Does anyone know if there is a way to change the callback function for a tag-like custom taxonomy so that it breaks terms after a semicolon instead of a comma? I realize I can rewrite the whole meta box, but I'd rather not if there's an easier way.
Does anyone know if there is a way to change the callback function for a tag-like custom taxonomy so that it breaks terms after a semicolon instead of a comma? I realize I can rewrite the whole meta box, but I'd rather not if there's an easier way.
Share Improve this question edited Apr 13, 2017 at 12:37 CommunityBot 1 asked Mar 15, 2013 at 20:07 gboonegboone 132 bronze badges1 Answer
Reset to default 3The tag delimiter is made translatable:
$comma = _x( ',', 'tag delimiter' );
So this can be changed with a simple filter:
add_filter( 'gettext_with_context', 't5_semicolon_tag_delimiter', 10, 4 );
function t5_semicolon_tag_delimiter( $translated, $text, $context, $domain )
{
if ( 'default' !== $domain or 'tag delimiter' !== $context or ',' !== $text )
return $translated;
return ';';
}
Install as plugin; works without any side effects.
What is tricky: changing the string Separate tags with commas to say semicolon. You cannot use the same solution, because you don’t know the language of your users. Not sure how to handle that.
Does anyone know if there is a way to change the callback function for a tag-like custom taxonomy so that it breaks terms after a semicolon instead of a comma? I realize I can rewrite the whole meta box, but I'd rather not if there's an easier way.
Does anyone know if there is a way to change the callback function for a tag-like custom taxonomy so that it breaks terms after a semicolon instead of a comma? I realize I can rewrite the whole meta box, but I'd rather not if there's an easier way.
Share Improve this question edited Apr 13, 2017 at 12:37 CommunityBot 1 asked Mar 15, 2013 at 20:07 gboonegboone 132 bronze badges1 Answer
Reset to default 3The tag delimiter is made translatable:
$comma = _x( ',', 'tag delimiter' );
So this can be changed with a simple filter:
add_filter( 'gettext_with_context', 't5_semicolon_tag_delimiter', 10, 4 );
function t5_semicolon_tag_delimiter( $translated, $text, $context, $domain )
{
if ( 'default' !== $domain or 'tag delimiter' !== $context or ',' !== $text )
return $translated;
return ';';
}
Install as plugin; works without any side effects.
What is tricky: changing the string Separate tags with commas to say semicolon. You cannot use the same solution, because you don’t know the language of your users. Not sure how to handle that.
本文标签: custom taxonomySeparate tags with semicolon
版权声明:本文标题:custom taxonomy - Separate tags with semicolon 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749132352a2320803.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论