wordpress code snippets part 1

to create menu in wordpree

<?
//add dynamic menu
add_action( 'init', 'register_my_menus' );
function register_my_menus() {
    register_nav_menus(
        array(
            'primary-menu' => __( 'Primary Menu' ),
            'secondary-menu' => __( 'Secondary Menu' ),
            'footer-menu' => __( 'Footer Menu' )
        )
    );
}
?>

to show a menu

<?php wp_nav_menu(array('theme_location' => 'primary-menu')); ?>



No comments:

Post a Comment