To set multiple terms for the $target_id, you can use a loop to iterate through the $pcat array and set each term individually using the wp_set_post_terms() function. Here's an example:

$target_id = 123; // Replace with the actual target post ID
$pcat = array(1, 2, 3); // Replace with the array of term IDs

foreach ($pcat as $term_id) {
    wp_set_post_terms($target_id, $term_id, 'qqcpat', true);
}

In the above code, the foreach loop iterates through each term ID in the $pcat array and sets it for the $target_id using wp_set_post_terms(). The true parameter at the end of the function call indicates that the terms should be appended to any existing terms for the post

wp_set_post_terms $target_id $pcat qqcpat ;	i have mutiple terms for target_idhow can i set it $pcat is an array of numbers like 123 etc

原文地址: https://www.cveoy.top/t/topic/iBIB 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录