ThemeShaper Forums » Thematic


WP 3 Menus in Autofocus+ Pro

(11 posts)
  • Started 11 years ago by nimrod
  • Latest reply from tbanh
  • This topic is resolved
  1. nimrod

    Has anyone tried or have any clue on adding WP 3 Menus feature to Autofocus+ Pro child theme?

    I notice there's a thematic-functions.php file in the theme folder with the following to add a "Home" link in the top main menu:

    //	Add a Home link to your menu
    function childtheme_menu_args($args) {
    		$args = array(
    		'show_home' => 'Home',
    		'sort_column' => 'menu_order',
    		'menu_class' => 'menu',
    		'echo' => true
    	return $args;

    I tried to adapt it to the suggested code for adding Menus to Thematic without success:

    add_theme_support( 'menus' );
    function child_access_menu() {
    	$menu_sys = 'wp_nav_menu';
    	return $menu_sys;
    add_filter('thematic_menu_type', 'child_access_menu');

    Any ideas...?

    Posted 11 years ago #
  2. nimrod

    Okay, the Autofocus author, Allen Cole, was kind enough to quickly respond and point me to the following forum post:

    The complicated one at the beginning works (and not the later simpler version posted by @em hr which is what I tried).

    So, all I did to get WP 3 Menus to work is open functions.php in the autofocuspro theme folder and paste the following as the last item above the closing ?> string:

    // We declare that our theme supports wp_nav_menu()
    add_theme_support( 'nav-menus' );
    // We Register the a new menu for the theme called "Primary Menu"
    function register_primary_menu() {
    	register_nav_menu( 'primary-menu', __( 'Primary Menu' ) );
    add_action( 'init', 'register_primary_menu' );
    // We remove the standard Thematic menu
    function remove_menu() {
    add_action('init', 'remove_menu');
    // We create the new wp_nav_menu called "Primary Menu" in our theme
    function new_access() { ?>
    	<div id="access">
    		<div class="skip-link"><a href="#content" title="<?php _e('Skip navigation to the content', 'thematic'); ?>"><?php _e('Skip to content', 'thematic'); ?></a></div><!-- .skip-link -->
    			<?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-menu', // we define this as being the previously registered "Primary Menu"
                              			'menu_class' => 'sf-menu', // we assign the sf-menu class to the menu ul so that superfish workds
                              			'container_class' => 'menu' // we assign the menu class to the menu container div so to keep it compatible with the Thematic menu styling
    	</div><!-- #access -->

    Remember that updates to the child theme from the author will overwrite any changes made!

    Posted 11 years ago #
  3. Hi,

    Heads up using add_theme_support in this way is not advised



    Posted 10 years ago #
  4. nimrod

    Okay, but does anyone have revised code to make WP 3 menus work (at least in AutoFocus Pro)?

    The linked page above seems to give only a warning about why not to do it.

    Posted 10 years ago #
  5. Hi Nimrod,
    I think i’m going to just go ahead and add the 3.0 menu functionality directly to AF+ Pro, especially after reading this post.

    I’m a little confused myself about what the best practice is when it comes to adding WP 3.0 menus to a Themtaic child theme. Things are clear on what NOT to do, but not so much on what we should be doing. I’m gonna fiddle with it a little and see what happens. I assume its because things are still in development and unstable.

    I’m shooting to have the WP 3.0 menus ready for a September update.

    Posted 10 years ago #
  6. nimrod

    That's swell 'cause I'm using Wp 3 menus in one project now and wanting to buy and develop another and possible a third Pro site as well by next month!

    Posted 10 years ago #
  7. Sounds great!

    I think I’ve figured this out. Here’s what I’ve got so far in my AF+ Dev install. Seems to work pretty solidly, but it seems like it requires a lot more code than it should:

    //	Custom Blog Header
    //	- Remove default Thematic blogtitle
    function remove_thematic_actions() {
    //	- Add the new menu function to the header
    function childtheme_access() { ?>
        	<div id="access">
        		<div class="skip-link"><a href="#content" title="<?php _e('Skip navigation to the content', 'thematic'); ?>"><?php _e('Skip to content', 'thematic'); ?></a></div>
    			<?php // Adds the conditional navigaton.
    			childtheme_header_nav(); ?>
            </div><!-- #access -->
    <?php }
    //	- Register Child Theme Navigation Menus
    if ( function_exists( 'add_theme_support' ) ) {
    	register_nav_menus( array(
    		'childtheme-header-menu' => __( 'Child Theme Header Menu', 'thematic' ),
    	) );
    //	- Child Theme Header navigation w/ conditionals
    //	-
    function childtheme_header_nav() {
        if ( function_exists( 'wp_nav_menu' ) )
    			wp_nav_menu( array(
    				'show_home' 	=> 'Home',
    				'sort_column'	=> 'menu_order',
    				'container_class' => 'menu',
    				'menu_class'	=> 'sf-menu',
    				'theme_location' => 'childtheme-header-menu',
    				'fallback_cb' => 'childtheme_header_nav_fallback'
    			) );
    //	- Set up a fall-back menu for the header just in case there are no menus in use.
    //	-
    function childtheme_header_nav_fallback() {
        wp_page_menu( array(
        	'show_home' => __('Home', 'thematic'),
        	'sort_column' => 'menu_order',
        	'depth' => '1',
        	'container_class' => 'menu'
        ) );

    I’ll have to play with it some more, but it seems to do the trick.

    Posted 10 years ago #
  8. nimrod

    That's great if a little deep.

    Just wondering how two or more menus would be added to this as well.

    Posted 10 years ago #
  9. Yeah, I’m adding 2 menu areas to the new Neutica+ update. So far it works, but the code is ugly. I’ll stick it here once I get it to a good place.

    Posted 10 years ago #
  10. hi Allen,
    I'm using the autofocus+ now and having problem with the wp custom menu to display, where should I paste in the script you mentioned above?

    my website: where it's missing 2 menu item from the WP Menus settings

    please advice, thanks

    Posted 10 years ago #
  11. *bump*

    has anyone solved the custom WP menus in Autofocus+ or Thematic and want to share the resolution with me?


    Posted 10 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.