在这段代码中;
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;
}