Php 如何仅在子菜单后获得下划线(不在父菜单后)
我在家长菜单后面画了下划线。我想在父菜单后加下划线,但如果有子菜单,我想在子菜单后加下划线。但问题是下划线后子菜单的打印。怎么办?有人能帮我吗Php 如何仅在子菜单后获得下划线(不在父菜单后),php,wordpress,loops,foreach,Php,Wordpress,Loops,Foreach,我在家长菜单后面画了下划线。我想在父菜单后加下划线,但如果有子菜单,我想在子菜单后加下划线。但问题是下划线后子菜单的打印。怎么办?有人能帮我吗 <?php foreach($menus as $menu) { if($menu->menu_item_parent == 0) { ?> <a id="fluid" href="#"><?php echo $menu
<?php
foreach($menus as $menu) {
if($menu->menu_item_parent == 0) { ?>
<a id="fluid" href="#"><?php echo $menu->title ?></a>
<hr class="divider">
<?php }
else{ ?>
<div id="parent-sub">
<a id="submenu" href="#"><?php echo $menu->title ?></a>
</div>
<?php }
} ?>
这将帮助您确定项目是否有子项
Array
(
[0] => WP_Post Object
(
[ID] => 712
[post_author] => 1
[post_date] => 2021-05-28 10:17:47
[post_date_gmt] => 2021-05-28 07:34:55
[post_content] =>
[post_title] =>
[post_excerpt] =>
[post_status] => publish
[comment_status] => closed
[ping_status] => closed
[post_password] =>
[post_name] => 712
[to_ping] =>
[pinged] =>
[post_modified] => 2021-05-28 10:17:47
[post_modified_gmt] => 2021-05-28 10:17:47
[post_content_filtered] =>
[post_parent] => 0
[guid] => http://localhost/fluid/?p=712
[menu_order] => 1
[post_type] => nav_menu_item
[post_mime_type] =>
[comment_count] => 0
[filter] => raw
[db_id] => 712
[menu_item_parent] => 0
[object_id] => 24
[object] => page
[type] => post_type
[type_label] => Page
[url] => http://localhost/fluid/fluid-difference/
[title] => Fluid Difference
[target] =>
[attr_title] =>
[description] =>
[classes] => Array
(
[0] =>
)
[xfn] =>
)
if ( $menu->has_children ) {
//has children
} else {
//does not have children
}