0

在这段代码中;

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;
}
4

1 回答 1

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;
}
于 2012-08-01T08:53:33.373 回答