Tuesday, January 10, 2012

Set limit wp_nav_menu

<?php $pages = wp_nav_menu( array( 'container_class' => 'menu1' ,'menu'=> 'Main Navigation','theme_location' => 'menu1', 'menu_class' => 'dropdown', 'echo' =>false,'container' => false ) );?>
<ul class="dropdown">
<?php
$limit = 5;

$pages_list = preg_replace(array('#^]*>#','#$#'), '', $pages);


$pages_arr = explode("\n", $pages_list);

for($i=0;$i<$limit;$i++){
    echo $pages_arr[$i];
}

?>
</ul>

1 comment:

Post a Comment