Tag Archives: code snippet

How to add new menu’s to a WordPress theme in the Functions.php file

Search for the register_nav_menus function and add some more menus to go other places in your theme.


// This theme uses wp_nav_menu() in one location.
register_nav_menus( array(
'primary' => __( 'Primary Navigation', 'twentyten' ),
'footer' => __( 'Footer Navigation', 'twentyten' ),
'sidebar' => __( 'Sidebar Navigation', 'twentyten' ),
) );

To insert your new menu somewhere in your theme files


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

How to register a new Widget area in the Funtions.php file

 <!--how to register a widget area -->
 	// Area 5, located on the home page. Empty by default.
	register_sidebar( array(
		'name' => __( 'Home Page Widget Area', 'twentyten' ),
		'id' => 'home-page-widget-area',
		'description' => __( 'The home page widget area', 'twentyten' ),
		'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
		'after_widget' => '</li>',
		'before_title' => '<h3 class="widget-title">',
		'after_title' => '</h3>',
	) );

Then in your template files use this code to call the widget area.

	<?php if ( is_active_sidebar( 'home-page-widget-area' ) ) : ?>
				<div id="home-second" class="home-widget-area">
					<ul class="xoxo">

						<?php dynamic_sidebar( 'home-page-widget-area' ); ?>
					</ul>
				</div><!-- #first .widget-area -->
<?php endif; ?>

How to Create a Custom post type by editing the functions.php file

/**how to register custom post type */
register_post_type('staff', array(
'label' => __('Staff'),
'singular_label' => __('Staff'),
'public' => true,
'show_ui' => true,
'capability_type' => 'post',
'hierarchical' => false,
'rewrite' => false, 'query_var' => true,
'supports' => array('title', 'editor', 'thumbnail'),
'taxonomies' => array( 'post_tag')
));