在此代码中;
if (!is_array($keywords)) {
$keywords = explode(',', $keywords);
}
foreach ($keywords as $thetag) {
wp_add_post_tags($post_id, $thetag);
}
如何限制添加到帖子中的标签数量?
这会有效吗
if (!is_array($keywords)) {
$count=0;
$keywords = explode(',', $keywords);
}
foreach ($keywords as $thetag) {
$count++;
wp_add_post_tags($post_id, $thetag);
if( $count > 3 ) break;
}
答案 0 :(得分:1)
是的,它有效!!!!!
if (!is_array($keywords)) {
$count=0;
$keywords = explode(',', $keywords);
}
foreach ($keywords as $thetag) {
$count++;
wp_add_post_tags($post_id, $thetag);
if( $count > 3 ) break;
}