Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.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下拉菜单帮助_Php_Wordpress_Menu_Drop Down Menu - Fatal编程技术网

需要PHP下拉菜单帮助

需要PHP下拉菜单帮助,php,wordpress,menu,drop-down-menu,Php,Wordpress,Menu,Drop Down Menu,需要我的简单PHP菜单的帮助。我想要这样:当子元素6显示两列。有什么建议吗 关于如果子菜单包含6个以上链接,我喜欢子菜单如下所示: Link Link Link Link 如果超过6个链接: Link Link Link Link Link Link 我正在使用WP,只需要如何制作它的建议。这里是基本的想法,您可以将其调整为与表格一起使用: if (count($childs) < 6) { foreach ($childs as $child) {

需要我的简单PHP菜单的帮助。我想要这样:当子元素<6显示一列时,如果>6显示两列。有什么建议吗


关于

如果子菜单包含6个以上链接,我喜欢子菜单如下所示:

Link
Link
Link
Link
如果超过6个链接:

Link Link
Link Link
Link Link

我正在使用WP,只需要如何制作它的建议。

这里是基本的想法,您可以将其调整为与表格一起使用:

if (count($childs) < 6)
{
    foreach ($childs as $child)
    { 
        echo htmlspecialchars($child)."<br>";
    }
}
else
{
    for ($n=0;$n<count($childs);$n++)
    {
        echo htmlspecialchars($child)." ";
        if ($n%2) echo "<br>";
    }
}
if(计数($child)<6)
{
foreach($childs作为$child)
{ 
echo htmlspecialchars($child)。“
”; } } 其他的 {
对于($n=0;$n可能会显示更多:当子链接6:链接我希望你现在知道我的意思。如果你编辑原始问题,你可以按照你想要的方式格式化输出。另外,你用什么来呈现菜单?也就是说,你有吗我有一个JavaScript框架,你在显示自定义的
元素吗?我用代码添加了答案。我使用jquery,只是不知道怎么做:(Carlos,是的,WordPress博客。我创建了自定义下拉菜单,但不知道怎么做:)谢谢你的建议!该死,我试着用一种好方法,但我的代码…有点乱:)
if (count($childs) < 6)
{
    // Single row
    echo "<tr>";
    foreach ($childs as $child)
    { 
        echo "<td>".htmlspecialchars($child)."</td>";
    }
    echo "</tr>";
}
else
{
    // Multiple row
    echo "<tr>";
    for ($n=0;$n<count($childs);$n++)
    {
        echo "<td>".htmlspecialchars($child)."</td>";
        if ($n%2) echo "</tr><tr>";
    }
    echo "</tr>";
}