PHP Logic
-
Hi, I have a fairly straight forward piece of PHP code:
<?php $menu_to_count = wp_nav_menu( array( 'theme_location' => 'primary', 'sub_menu' => true, 'echo' => false ) ); $menu_items = substr_count( $menu_to_count, 'class="menu-item ' ); if ( $menu_items != 0 ) { wp_nav_menu( array('theme_location' => 'primary','sub_menu' => true,'direct_parent' => true) ); } else { echo "none"; } ?>The problem is the line wp_nav_menu( array(‘theme_location’ => ‘primary’,’sub_menu’ => true,’direct_parent’ => true) ) for when it evaluates to true. If I change that to a simple echo (“yes”) then it is fine – which means I must be missing some logic. Any thoughts?
The topic ‘PHP Logic’ is closed to new replies.