Thursday 20 June 2013

DF Marine Menu - Swap with a normal Menu.

The Menu on the theme DF_Marine is rather baffling .  As you can't control it from the normal access for a menu.

Looking at the code for it in /wp-content/themes/df_marine/header.php we get this code.

                $today = current_time('mysql', 1);
            if ( $recentposts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'publish' AND post_date_gmt < '$today' ORDER BY post_date DESC LIMIT 5")):
        ?>
            
                  post_title == '') $post->post_title = sprintf(__('Post #%s'), $post->ID);             echo "
  • "; the_title(); echo '
  • '; }?>            
           



Let's have a look how a Menu is normall called up


And in functions.php

register_nav_menus( array(
        'header-menu' => __( 'Header Menu', 'littleripples' ),
    ) );


Here's some information on it in the Wordpress Function Reference.

http://codex.wordpress.org/Function_Reference/wp_nav_menu

To fix the df_marine theme menu issue .  Here's what I did .  Please use a child theme as I did for this, however I'll explain the changes as if hacking the main theme.

OPEN df_marine/header.php

FIND
if ( $recentposts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'publish' AND post_date_gmt < '$today' ORDER BY post_date DESC LIMIT 5")):
        ?>
            
                  post_title == '') $post->post_title = sprintf(__('Post #%s'), $post->ID);             echo "
  • "; the_title(); echo '
  • '; }?>            
           


REPLACE WITH

     'menu-header', 'theme_location' => 'primary' ) ); ?>
                



SAVE


OPEN wp-content/themes/twentyten/functions.php 

register_nav_menus( array(
        'primary' => __( 'Primary Navigation', 'twentyten' ),
    ) );



SAVE

UPLOAD BOTH FILES

You'll now have a dropdown box in the admin area, where you can select a menu you set up .

goto
admin > appearance > menus 
see the 'Theme Locations' box on the left there.  See this image.  


change done for www.cameltrailcyclehire.co.uk

No comments: