Featured in DMM v1.7
DMM = the Desk Mess Mirrored theme
Just a quick preview of one of the upcoming featured changes to the Desk Mess Mirrored theme: custom menus via the wp_nav_menu() function.
The current code for Desk Mess Mirrored version 1.6 in header.php for menus is this (cleaned up for display):
<?php if ( is_home() || is_front_page()) { ?>
<?php wp_list_pages( 'title_li=&depth=1&include=2' ); ?>
<?php wp_list_pages( 'title_li=&depth=1&exclude=2' ); ?>
<?php } else { ?>
<li><a href="<?php bloginfo( 'url' ); ?>"><?php _e( 'Home', 'desk-mess-mirrored' ) ?></a></li>
<?php wp_list_pages( 'title_li=&depth=1' ); ?>
<?php } ?>
All of that code is simply replaced by this line:
<?php dmm_nav_menu(); ?>
The function dmm_nav_menu() is referring to this section of code now found in the functions.php template file:
// Add wp_nav_menu() custom menu support
add_theme_support( 'menus' );
function dmm_nav_menu() {
if ( function_exists( 'wp_nav_menu' ) )
wp_nav_menu( array(
'theme_location' => 'top-menu',
'depth' => 1,
'fallback_cb' => 'dmm_list_pages'
) );
else
dmm_list_pages();
}
function dmm_list_pages() {
if ( is_home() || is_front_page() ) {
wp_list_pages( 'title_li=&depth=1' );
} else { ?>
<li><a href="<?php bloginfo( 'url' ); ?>"><?php _e( 'Home', 'desk-mess-mirrored' ) ?></a></li>
<?php wp_list_pages( 'title_li=&depth=1' );
}
}
add_action( 'init', 'register_dmm_menu' );
function register_dmm_menu() {
register_nav_menu( 'top-menu', __( 'Top Menu' ) );
}
// wp_nav_menu() end
Notice the highlighted lines are identical which means at the default settings after updating to version 1.7 you should see no difference in how your site looks, but you are now able to set the menu links using the interface under Appearance | Menus. Also note, the menu is still set as a top-level or parent only menu. Future versions of DMM may offer drop-down menus and other options but they are not currently scheduled for a particular release date or version at this time.
All of these changes were based on the article I wrote at WPFirstAid.com titled: Upgrade wp_list_pages() to wp_nav_menu().
Enjoy!
© 2010, BuyNowShop. All rights reserved.
Related posts:
- Desk Mess Mirrored 1.5
- Desk Mess Mirrored 1.2
- Desk Mess Mirrored 1.6
- Desk Mess Mirrored 1.0.9
- Hide a Menu Page
Tags: custom menu, desk mess mirrored, update, WPFirstAid
Try Our Themes
Buy me a coffee?
... or grant an Amazon wishCalendar
Learn WordPress
Adding Some Ajax?
Freelancing?
Need a Host?
Gravity Forms
Need a Forum?
a la Carte
Categories
- CSS (4)
- News (71)
- Showcases (4)
- Uncategorized (2)
- WordPress (84)
WordPress
Category: WordPress
Category: Showcases
Tag: Update
Desk Mess Mirrored 1.7The free WordPress.org Theme Desk Mess Mirrored version 1.7 is now available as of Aug 5, 2010.
Ground Floor 1.5.1The free WordPress Theme Ground Floor version 1.5.1 is now available at WordPress.org as of Jul 26, 2010.
Featured in DMM v1.7The custom menu code featured in the free WordPress theme Desk Mess Mirrored version 1.7
Archives
- August 2010 (2)
- July 2010 (2)
- June 2010 (3)
- May 2010 (1)
- April 2010 (8)
- March 2010 (2)
- February 2010 (7)
- January 2010 (5)
- December 2009 (5)
- November 2009 (9)
- October 2009 (6)
- September 2009 (11)
- August 2009 (13)
- July 2009 (7)
- June 2009 (8)
- May 2009 (4)
-
Canned Goods



@Yamasha – Look for them to be better implemented in DMMv1.7; in the mean time you should be able to add this snippet of code right before the_content() in ‘index.php’ to add them right now:
<?php if ( has_post_thumbnail() ) { the_post_thumbnail( 'thumbnail', array( 'class' => 'alignleft' ) ); } ?>@Yamasha – I took a quick look using DMMv1.7 and the plugin appears to work. I would suggest waiting for version 1.7 to be released in the WordPress Themes repository.
@Yamasha – The new version has already been released, it is just waiting for its turn in the review queue at the WordPress.org repository.