當前位置: 首頁>>代碼示例>>PHP>>正文


PHP wp_nav_menu函數代碼示例

本文整理匯總了PHP中wp_nav_menu函數的典型用法代碼示例。如果您正苦於以下問題:PHP wp_nav_menu函數的具體用法?PHP wp_nav_menu怎麽用?PHP wp_nav_menu使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了wp_nav_menu函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: widget

    function widget($args, $instance)
    {
        extract($args);
        // Get menu
        if (!isset($instance['speed'])) {
            $instance['speed'] = 'slow';
        }
        $widget_options = wp_parse_args($instance, $this->defaults);
        extract($widget_options, EXTR_SKIP);
        $nav_menu = wp_get_nav_menu_object($instance['nav_menu']);
        if (!$nav_menu) {
            return;
        }
        $instance['title'] = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
        $classMenu = $instance['classMenu'] != '' ? $instance['classMenu'] : 'menu';
        echo $args['before_widget'];
        if (!empty($instance['title'])) {
            echo $args['before_title'] . $instance['title'] . $args['after_title'];
        }
        ?>
		
		<div class="dcjq-accordion" id="<?php 
        echo $this->id . '-item';
        ?>
">
		
			<?php 
        wp_nav_menu(array('fallback_cb' => '', 'menu' => $nav_menu, 'container' => false, 'menu_class' => $classMenu));
        ?>
		
		</div>
		<?php 
        echo $args['after_widget'];
    }
開發者ID:healthcommcore,項目名稱:osnap,代碼行數:34,代碼來源:dcwp_jquery_accordion_widget.php

示例2: header_style

function header_style()
{
    $nav_items = wp_nav_menu(array('echo' => false, 'theme_location' => 'primary', 'depth' => 1));
    $nav_items_count = substr_count($nav_items, 'class="menu-item ');
    $nav_item_width = 100 / $nav_items_count - 0.3;
    return "<style type='text/css'>\n\n\t\t\t\t.nav ul li, .footer-nav ul li {\n\t\t\t\t\twidth: " . $nav_item_width . "%;\n\t\t\t\t}\n\t\t\t</style>";
}
開發者ID:jdillman1989,項目名稱:Composer-WP-Theme,代碼行數:7,代碼來源:functions.php

示例3: widget

 public function widget($args, $instance)
 {
     // Get menu
     $nav_menu = !empty($instance['nav_menu']) ? wp_get_nav_menu_object($instance['nav_menu']) : false;
     if (!$nav_menu) {
         return;
     }
     /** This filter is documented in wp-includes/default-widgets.php */
     $instance['title'] = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
     echo $args['before_widget'];
     if (!empty($instance['title'])) {
         echo $args['before_title'] . $instance['title'] . $args['after_title'];
     }
     $nav_menu_args = array('fallback_cb' => '', 'menu' => $nav_menu, 'container-class' => 'container-fluid', 'items_wrap' => '<ul id="%1$s" class="nav nav-sidebar">%3$s</ul>', 'depth' => 1);
     /**
      * Filter the arguments for the Custom Menu widget.
      *
      * @since 4.2.0
      *
      * @param array    $nav_menu_args {
      *     An array of arguments passed to wp_nav_menu() to retrieve a custom menu.
      *
      *     @type callback|bool $fallback_cb Callback to fire if the menu doesn't exist. Default empty.
      *     @type mixed         $menu        Menu ID, slug, or name.
      * }
      * @param stdClass $nav_menu      Nav menu object for the current menu.
      * @param array    $args          Display arguments for the current widget.
      */
     wp_nav_menu(apply_filters('widget_nav_menu_args', $nav_menu_args, $nav_menu, $args));
     echo $args['after_widget'];
 }
開發者ID:eggmatters,項目名稱:monsoon-responsive,代碼行數:31,代碼來源:MR_Widgets.php

示例4: widget

 /**
  * Outputs the content for the current Custom Menu widget instance.
  *
  * @since 3.0.0
  * @access public
  *
  * @param array $args     Display arguments including 'before_title', 'after_title',
  *                        'before_widget', and 'after_widget'.
  * @param array $instance Settings for the current Custom Menu widget instance.
  */
 public function widget($args, $instance)
 {
     // Get menu
     $nav_menu = !empty($instance['nav_menu']) ? wp_get_nav_menu_object($instance['nav_menu']) : false;
     if (!$nav_menu) {
         return;
     }
     /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
     $instance['title'] = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
     echo $args['before_widget'];
     if (!empty($instance['title'])) {
         echo $args['before_title'] . $instance['title'] . $args['after_title'];
     }
     $nav_menu_args = array('fallback_cb' => '', 'menu' => $nav_menu);
     /**
      * Filter the arguments for the Custom Menu widget.
      *
      * @since 4.2.0
      * @since 4.4.0 Added the `$instance` parameter.
      *
      * @param array    $nav_menu_args {
      *     An array of arguments passed to wp_nav_menu() to retrieve a custom menu.
      *
      *     @type callable|bool $fallback_cb Callback to fire if the menu doesn't exist. Default empty.
      *     @type mixed         $menu        Menu ID, slug, or name.
      * }
      * @param stdClass $nav_menu      Nav menu object for the current menu.
      * @param array    $args          Display arguments for the current widget.
      * @param array    $instance      Array of settings for the current widget.
      */
     wp_nav_menu(apply_filters('widget_nav_menu_args', $nav_menu_args, $nav_menu, $args, $instance));
     echo $args['after_widget'];
 }
開發者ID:qaryas,項目名稱:qaryas_site,代碼行數:43,代碼來源:class-wp-nav-menu-widget.php

示例5: vc_menu_func

function vc_menu_func($atts, $content)
{
    ob_start();
    ?>
	<nav class="navbar navbar-default" id="menunav">
				<div class="container">
					<div class="row">
						<ul class="nav navbar-nav pull-right margin-right-15">
							<li class="dropdown resv-dropdown" id="ibe-dropdown">
								<a class="resv-link dropdown-toggle" href="#back-to-reserve" id="ibe-dropdown-button"><?php 
    echo esc_html(get_theme_mod('booking_button_text', esc_attr__('Reservations', 'Property Theme')));
    ?>
								</a>
							</li>
						</ul>

						<?php 
    if (has_nav_menu('primary_navigation')) {
        wp_nav_menu(['theme_location' => 'primary_navigation', 'menu_class' => 'nav navbar-nav navbar-right']);
    }
    ?>
					</div>
				</div>
			</nav>
	<?php 
    $returnvariable = ob_get_clean();
    return $returnvariable;
}
開發者ID:ratheeshpkr,項目名稱:snhotel,代碼行數:28,代碼來源:snhotel-vc_addons.php

示例6: bigblank_footer_menu_fallback

 /**
  * Footer menu fallback
  */
 function bigblank_footer_menu_fallback()
 {
     $menus = wp_get_nav_menus();
     if (!empty($menus)) {
         return wp_nav_menu(array('container' => 'nav', 'depth' => 1, 'container_id' => 'footer-nav'));
     }
 }
開發者ID:victorknust,項目名稱:BigBlankTheme,代碼行數:10,代碼來源:template-tags.php

示例7: widget

 /**
  * load widget
  *
  * @name    widget
  * @author  Marcelo Mesquita <marcelo.costa@cultura.gov.br>
  * @since   2012-12-30
  * @updated 2012-04-25
  * @param   array $args - widget structure
  * @param   array $instance - widget data
  * @return  void
  */
 function widget($args, $instance)
 {
     global $wpdb;
     if (function_exists('switch_to_blog')) {
         switch_to_blog($instance['blog']);
     }
     if (is_multisite()) {
         $site_path = $wpdb->get_var($wpdb->prepare("SELECT path FROM {$wpdb->blogs} WHERE blog_id = 1"));
         $blog_path = $wpdb->get_var($wpdb->prepare("SELECT path FROM {$wpdb->blogs} WHERE blog_id = %d", get_current_blog_id()));
         $area = str_replace(array($site_path, '/'), '', $blog_path);
     }
     $blog_url = get_bloginfo('url');
     // show tags
     print $args['before_widget'];
     if (!empty($instance['title'])) {
         print $args['before_head'];
         print $args['before_title'] . $instance['title'] . $args['after_title'];
         print $args['after_head'];
     }
     print $args['before_body'];
     wp_nav_menu("menu={$instance['menu']}");
     print $args['after_body'];
     print $args['after_widget'];
     if (function_exists('restore_current_blog')) {
         restore_current_blog();
     }
 }
開發者ID:CoordCulturaDigital-Minc,項目名稱:setoriais,代碼行數:38,代碼來源:sav-widget-custom-menu.php

示例8: ds_add_top_header

function ds_add_top_header()
{
    $enable_header_top = esc_attr(get_theme_mod('dt_enable_header_top', DT_ENABLE_HEADER_TOP));
    if ($enable_header_top != '1') {
        return;
    }
    ?>
    <div class="ds-top-header">
        <div class="container">
            <div class="ds-top-header-inner">
                <div class="ds-top-head-left">
                    <?php 
    if (display_header_text()) {
        echo get_bloginfo('description', 'display');
    }
    ?>
                </div>
                <div class="ds-top-head-right">
                    <?php 
    wp_nav_menu(array('theme_location' => 'header-top', 'container_class' => 'header_top_menu', 'menu_class' => 'ds-top-menu-ul'));
    ?>
                </div>
            </div>
        </div>
    </div>
    <?php 
}
開發者ID:mistergiri,項目名稱:directory-starter,代碼行數:27,代碼來源:custom.php

示例9: msd_inline_menu

function msd_inline_menu($atts)
{
    extract(shortcode_atts(array('menu' => 'primary-links', 'walker' => 'msd_icon_desc_walker'), $atts));
    $walker = new $walker();
    $defaults = array('menu' => $menu, 'container' => 'div', 'container_class' => '', 'container_id' => '', 'menu_class' => 'menu', 'menu_id' => '', 'echo' => false, 'fallback_cb' => 'wp_page_menu', 'before' => '', 'after' => '', 'link_before' => '<h3>', 'link_after' => '</h3>', 'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s</ul>', 'depth' => 0, 'walker' => $walker);
    return wp_nav_menu($defaults);
}
開發者ID:foxydot,項目名稱:madvia,代碼行數:7,代碼來源:shortcodes.php

示例10: listify_tertiary_menu

function listify_tertiary_menu()
{
    global $post;
    $enabled = get_post_meta($post->ID, 'enable_tertiary_navigation', true);
    if (1 != $enabled) {
        return;
    }
    ob_start();
    wp_nav_menu(array('theme_location' => 'tertiary', 'container_class' => 'navigation-bar nav-menu', 'menu_class' => 'tertiary nav-menu'));
    $menu = ob_get_clean();
    if ('' == $menu) {
        return;
    }
    remove_filter('the_title', 'wc_page_endpoint_title');
    ?>
	<nav class="tertiary-navigation" role="navigation">
		<div class="container">
			<a href="#" class="navigation-bar-toggle">
				<i class="ion-navicon-round"></i>
				<?php 
    echo listify_get_theme_menu_name('tertiary');
    ?>
			</a>
			<div class="navigation-bar-wrapper">
				<?php 
    echo $menu;
    ?>
			</div>
		</div>
	</nav><!-- #site-navigation -->
<?php 
    add_filter('the_title', 'wc_page_endpoint_title');
}
開發者ID:abdullahrahim,項目名稱:shadighar,代碼行數:33,代碼來源:template-tags.php

示例11: atp_secondary_menu

 function atp_secondary_menu()
 {
     if (has_nav_menu('secondary-menu')) {
         wp_nav_menu(array('container' => false, 'theme_location' => 'secondary-menu', 'menu_class' => 'sf-menu', 'echo' => true, 'before' => '', 'after' => '', 'link_before' => '', 'link_after' => '', 'depth' => 0, 'walker' => new description_walker()));
     } else {
     }
 }
開發者ID:pryspry,項目名稱:MusicPlay,代碼行數:7,代碼來源:atp_generator.php

示例12: bfa_new_wp3_menus

function bfa_new_wp3_menus($theme_location = "menu1", $alignment = "left")
{
    $before_menu = '';
    $after_menu = '';
    /*
    if ( $theme_location == "menu1" ) $menu_id = "rmenu2-page";
    if ( $theme_location == "menu2" ) $menu_id = "rmenu-cat";
    */
    if ($theme_location == "menu1") {
        $menu_id = "rmenu2";
    }
    if ($theme_location == "menu2") {
        $menu_id = "rmenu";
    }
    $menu_class = "clearfix rMenu-hor rMenu";
    if ($alignment == "right") {
        $menu_class .= " rMenu-hRight";
    }
    if ($alignment == "center") {
        if ($theme_location == "menu1") {
            $before_menu = '<div id="bfa_page_menu"><table cellpadding="0" cellspacing="0" style="margin: 0 auto"><tr><td align="center">';
        }
        if ($theme_location == "menu2") {
            $before_menu = '<div id="bfa_cat_menu"><table cellpadding="0" cellspacing="0" style="margin: 0 auto"><tr><td align="center">';
        }
        $after_menu = '</td></tr></table></div>';
    }
    ob_start();
    wp_nav_menu(array('theme_location' => $theme_location, 'container' => 'div', 'container_id' => $theme_location, 'menu_class' => $menu_class, 'menu_id' => $menu_id, 'link_before' => '<span>', 'link_after' => '</span>'));
    $newmenu = ob_get_contents();
    ob_end_clean();
    $newmenu = preg_replace("/<li (.*?)class=\"(.*?)\">(.*?)\n(.*?)<ul class=\"/i", "<li \\1 class=\"rMenu-expand \\2\">\\3\n\\4<ul class=\"rMenu-ver ", $newmenu);
    return $before_menu . $newmenu . $after_menu;
}
開發者ID:ricofreak,項目名稱:wordPressBlog,代碼行數:34,代碼來源:bfa_new_wp3_menus.php

示例13: add_section_menu

 /**
  * Add Section Menu
  * Matches a menu and location to the Section Page slug
  *
  * @author Jordan Pakrosnis
  */
 function add_section_menu()
 {
     $post = get_post();
     $section_menu_args = array('menu' => $post->post_name, 'container' => 'nav', 'container_class' => 'section-menu', 'echo' => true, 'depth' => 2);
     // Output Menu
     wp_nav_menu($section_menu_args);
 }
開發者ID:JordanPak,項目名稱:UCFBands,代碼行數:13,代碼來源:menus.php

示例14: toolset_starter_menu

function toolset_starter_menu($menu_position, $menu_class, $menu_container_class)
{
    ?>
<nav class="<?php 
    echo $menu_container_class;
    ?>
" role="navigation">
	<?php 
    if ($menu_position === 'static-top' || $menu_position === 'fixed-top') {
        echo '<div class="container">';
    }
    ?>
	<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
		<span class="sr-only"><?php 
    _e('Toggle navigation', "toolset_starter");
    ?>
</span>
		<span class="icon-bar"></span>
		<span class="icon-bar"></span>
		<span class="icon-bar"></span>
	</button>
	<div class="collapse navbar-collapse" id="nav-main">
		<?php 
    wp_nav_menu(array('theme_location' => 'header-menu', 'depth' => 5, 'menu_class' => $menu_class, 'fallback_cb' => 'wpbootstrap_menu_fallback', 'walker' => new Wpbootstrap_Nav_Walker()));
    ?>
<!-- #nav-main -->
	</div><!-- .navbar-collapse -->
	<?php 
    if ($menu_position === 'static-top' || $menu_position === 'fixed-top') {
        echo '</div>';
    }
    ?>
</nav><!-- .navbar -->
<?php 
}
開發者ID:twelch555,項目名稱:core_toolsetstarter,代碼行數:35,代碼來源:header.php

示例15: get_menu

 public static function get_menu()
 {
     if (!self::$_menu) {
         self::$_menu = wp_nav_menu(array('theme_location' => 'social', 'menu_class' => 'social-menu', 'echo' => false, 'depth' => 0, 'fallback_cb' => ''));
     }
     return self::$_menu;
 }
開發者ID:Teplitsa,項目名稱:giger,代碼行數:7,代碼來源:class-statics.php


注:本文中的wp_nav_menu函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。