Advertisement
arnabkumar

menu_&_widgets

Mar 30th, 2014
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.30 KB | None | 0 0
  1. <?php
  2.  
  3. /* 1. menu simple function e *//*main-menu hare unic you can change it*//* Main Menu hare menu name display*/
  4.  
  5. register_nav_menu( 'main-menu', __( 'Main Menu', 'arnab' ) );
  6.  
  7. /* menu call korte *//*html e ul id/class="nav" thakleo menu id/class nav dile hobe */
  8.                                                /* nav poriborte onno class/id thakte pare */
  9.  
  10. <?php wp_nav_menu( array( 'theme_location' => 'main-menu', 'menu_id' => 'nav') ); ?>
  11.  
  12.  
  13.  
  14. /* 2. fallback menu register e register *//* 1st simple menu hobe then fallback code */
  15. register_nav_menu( 'main-menu', __( 'Main Menu', 'arnab' ) );
  16.  
  17.  
  18.     /* menu fallback code */
  19.     function wpj_default_menu() {
  20.         echo '<ul id="nav">';   /* ul id r bodole div/class id hote pare html jamon thakbe */
  21.         if ('page' != get_option('show_on_front')) {
  22.         echo '<li><a href="'. home_url() . '/">Home</a></li>';
  23.         }
  24.         wp_list_pages('title_li=');
  25.         echo '</ul>';
  26.     }
  27.    
  28. /* menu call korte*//*wp_nav_menu hare wordpress function*/
  29. /* menu id r jaygay class thakle menu_class hobe */
  30. /* jodi id or class na thake tahole sudhu theme location hobe
  31. mane je name menu register kora hobe*/
  32.  
  33. <?php
  34.                 if (function_exists('wp_nav_menu')) {
  35.                     wp_nav_menu(array('theme_location' => 'main-menu', 'menu_id' => 'nav', 'fallback_cb' => 'wpj_default_menu'));
  36.                 }
  37.                 else {
  38.                     wpj_default_menu();
  39.                 }
  40.                 ?>
  41.  
  42.  
  43.  
  44.  
  45. /* menu extra option from codex */
  46.  Usage
  47.  
  48.  <?php wp_nav_menu( $args ); ?>  
  49.  
  50.  Usage (Showing Default Values)
  51.  
  52. <?php
  53.  
  54. $defaults = array(
  55.     'theme_location'  => '',
  56.     'menu'            => '',
  57.     'container'       => 'div',
  58.     'container_class' => '',
  59.     'container_id'    => '',
  60.     'menu_class'      => 'menu',
  61.     'menu_id'         => '',
  62.     'echo'            => true,
  63.     'fallback_cb'     => 'wp_page_menu',
  64.     'before'          => '',
  65.     'after'           => '',
  66.     'link_before'     => '',
  67.     'link_after'      => '',
  68.     'items_wrap'      => '<ul id="%1$s" class="%2$s">%3$s</ul>',
  69.     'depth'           => 0,
  70.     'walker'          => ''
  71. );
  72.  
  73. wp_nav_menu( $defaults );
  74.  
  75. ?>
  76.  
  77. /* end menu extra option from codex */
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91. /* Register sidebars and widgetized areas ********************************************/
  92. function sanchari_widgets() {
  93.     register_sidebar( array(
  94.         'name'          => __( 'Promo1', 'wp_sourse' ),/*This name is unique
  95.                                                         to the widget and appears on
  96.                                                         the Widgets page on the Dashboard;
  97.                                                         this name is helpful if you register
  98.                                                         several widgetized areas on your site. */
  99.        
  100.  
  101.         'id'            => 'promo1',/*This is the unique ID given to the widget. */
  102.         'description' => __( ‘The primary widget area’),/* This is a text description
  103.                                                             of the widget. The text appears on
  104.                                                             the Widgets page on the Dashboard.
  105.                                                             This is optional.
  106.                                                             */
  107.        
  108.         'before_widget' => '<div class="single_promo promo1">',/* */
  109.         'after_widget'  => '</div>',/* */
  110.         'before_title'  => '<h2>',/* */
  111.         'after_title'   => '</h2>',/* */
  112.     ) );
  113.    
  114.  
  115. }
  116. add_action( 'widgets_init', 'sanchari_widgets' );
  117.  
  118. /* widgetized call two types */
  119. /*1. *****Normal****   */
  120.  
  121. <?php dynamic_sidebar('sidebar_id'); ?>
  122.  
  123. /* 2.*******for fallback data******** */
  124.  
  125. <?php if ( ! dynamic_sidebar('sidebar_id') ) : ?>
  126.     YOUR DEFAULT DATA
  127. <?php endif; ?>
  128.    
  129.  
  130. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement