Title: Add function? (I may be using the wrong term.)
Last modified: August 20, 2016

---

# Add function? (I may be using the wrong term.)

 *  [gulliver](https://wordpress.org/support/users/gulliver/)
 * (@gulliver)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/add-function-i-may-be-using-the-wrong-term/)
 * How do I add a new function?
 * The header in the theme i’m using also includes the main navigation bar; I’d 
   prefer to remove the main navigation and add something like <?php get_main-nav();?
   > to the templates so the main nav is called in the same way as the header is
   called by <?php get_header(); ?>

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [Digital Raindrops](https://wordpress.org/support/users/adeptris/)
 * (@adeptris)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/add-function-i-may-be-using-the-wrong-term/#post-2301960)
 * Which theme and a link to the website would help, the menu could be theme dependent.
 * Do you want just to tidy the code, or make the menu conditional?
 * If inside the header.php there is a call to [wp_nav_menu()](http://codex.wordpress.org/Function_Reference/wp_nav_menu)
   then you might be able to deal with this with an empty callback.
 * For more tidy code you could also add the menu block to a [template part](http://codex.wordpress.org/Function_Reference/get_template_part),
   but it is not clear why you want to do this, but here is what I would do in a
   twenty eleven theme child theme.
 * I would copy the header.php to the [child theme](http://codex.wordpress.org/Child_Themes),
   and then copy this block of code to a file called **navigation-main.php**
 *     ```
       <nav id="access" role="navigation">
       	<h3 class="assistive-text"><?php _e( 'Main menu', 'twentyeleven' ); ?></h3>
       	<?php /*  Allow screen readers / text browsers to skip the navigation menu and get right to the good stuff. */ ?>
       	<div class="skip-link"><a class="assistive-text" href="#content" title="<?php esc_attr_e( 'Skip to primary content', 'twentyeleven' ); ?>"><?php _e( 'Skip to primary content', 'twentyeleven' ); ?></a></div>
       	<div class="skip-link"><a class="assistive-text" href="#secondary" title="<?php esc_attr_e( 'Skip to secondary content', 'twentyeleven' ); ?>"><?php _e( 'Skip to secondary content', 'twentyeleven' ); ?></a></div>
       	<?php /* Our navigation menu.  If one isn't filled out, wp_nav_menu falls back to wp_page_menu. The menu assiged to the primary position is the one used. If none is assigned, the menu with the lowest ID is used. */ ?>
       	<?php wp_nav_menu( array( 'theme_location' => 'primary' ) ); ?>
       </nav><!-- #access -->
       ```
   
 * And replace it with:
    `<?php get_template_part('navigation','main'); ?>`
 * This is just a cleaner way of coding, look at the files in twenty eleven and 
   you will see it is used a lot now.
 * As an example I added [two extra menus](http://digitalraindrops.net/2011/09/twenty-eleven-three-menus/)
   to a theme and used template parts to minimise the changes to the existing files.
 * HTH
 * David
 *  Thread Starter [gulliver](https://wordpress.org/support/users/gulliver/)
 * (@gulliver)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/add-function-i-may-be-using-the-wrong-term/#post-2302018)
 * David, thanks very much. That’s really appreciated.
 * It’s helped me to better understand WP.
 * The particular theme is an adapted variant of ‘Fresh and clean’, and following
   your template suggestions things are now as I want.
 * My reason was to tidy the code, although I can now see how I can use this conditionally
   should the need arise.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Add function? (I may be using the wrong term.)’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [gulliver](https://wordpress.org/support/users/gulliver/)
 * Last activity: [14 years, 9 months ago](https://wordpress.org/support/topic/add-function-i-may-be-using-the-wrong-term/#post-2302018)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
