Php 如何设置类别列表限制?
我正在显示帖子类别子列表。列表显示全部 我只需要显示6(儿童) 帮助我们 例: 菜单(父菜单) 清单1(儿童) 清单2(儿童) 清单3(儿童) 清单4(儿童) 清单5(儿童) 清单6(儿童) 清单7(儿童) 清单8(儿童)Php 如何设置类别列表限制?,php,wordpress,wordpress-theming,Php,Wordpress,Wordpress Theming,我正在显示帖子类别子列表。列表显示全部 我只需要显示6(儿童) 帮助我们 例: 菜单(父菜单) 清单1(儿童) 清单2(儿童) 清单3(儿童) 清单4(儿童) 清单5(儿童) 清单6(儿童) 清单7(儿童) 清单8(儿童) 您可以在get\u categories函数中使用user number=6,如 $talentChildren = get_categories(array('child_of' => get_category_by_slug('news')->ter
-
您可以在get\u categories函数中使用user number=6,如
$talentChildren = get_categories(array('child_of' => get_category_by_slug('news')->term_id,'number' => 6,'hide_empty' => 0));
foreach($talentChildren as $talent):
echo "<pre>";
print_r($talent);
echo "</pre>";
endforeach;
$talentChildren=get_categories(数组('child_of'=>get_categories_by_slug('news')->term_id,'number'=>6,'hide_empty'=>0));
foreach($talentChildren作为$talent):
回声“;
印刷(人才);
回声“;
endforeach;
i receive->syntax error,意外“=>”(T\u双箭头)如何解决此错误您尝试过吗?工作?stdClass对象([term\u id]=>23[name]=>Directors[slug]=>Directors[term\u group]=>0[term\u taxonomy\u id]=>24[taxonomy]=>category[description]=>parent]=>15[count]=>6[cat\u id]=>23[category\u count]=>6[category\u description]=>Directors[category\u nicename]=>Directors[category\u parent]=>15)工作正常,还有其他帮助。现在显示[slug]=>Directors[count]=>display 6。我只需要显示2。与我们的帮助您可以将数字更改为2
$talentChildren = get_categories(array('child_of' => get_category_by_slug('news')->term_id,'number' => 6,'hide_empty' => 0));
foreach($talentChildren as $talent):
echo "<pre>";
print_r($talent);
echo "</pre>";
endforeach;