Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何使用wordpress中的脚本创建类别的子类别?_Php_Wordpress - Fatal编程技术网

Php 如何使用wordpress中的脚本创建类别的子类别?

Php 如何使用wordpress中的脚本创建类别的子类别?,php,wordpress,Php,Wordpress,正如我尝试使用这段代码时所做的那样,这似乎很好,但只创建了很少的子类别,很少没有创建子类别。我不明白问题所在。如果有什么遗漏,请告诉我 $catIdOfTransport='112'; wp_create_category('car',$catIdOfTransport) ; $arr=array('maruti','nano','bmw'); $val=count($arr); for($j=0;$j<$val;$j++){ wp_create_category( $arr[$j], '

正如我尝试使用这段代码时所做的那样,这似乎很好,但只创建了很少的子类别,很少没有创建子类别。我不明白问题所在。如果有什么遗漏,请告诉我

$catIdOfTransport='112';
wp_create_category('car',$catIdOfTransport) ;
$arr=array('maruti','nano','bmw');
$val=count($arr);
for($j=0;$j<$val;$j++){ wp_create_category( $arr[$j], 'car'); }    
$catIdOfTransport='112';
wp_创建_类别('car',$catIdOfTransport);
$arr=array('maruti','nano','bmw');
$val=计数($arr);
对于($j=0;$jwp\u创建\u类别($value,$parent)

$valow=strtolower($value);
$slugcre=str_replace(“,”-“,$valow);
$slugname=$slugcre.“-transpost”;
$idObj=按slug获取类别($slugname);
$id=$idObj->term\u id;
$parent1=$id;
$val=计数($arr[$i]);
对于($j=0;$j),应在
    $valow=strtolower($values);
    $slugcre=str_replace(" ","-",$valow);
    $slugname=$slugcre."-transpost";
    $idObj = get_category_by_slug($slugname); 

    $id = $idObj->term_id;
    $parent1=$id;
    $val=count($arr[$i]);

    for($j=0;$j<$val;$j++)
             {
                wp_create_category( $arr[$i][$j], $parent1);
             }