{"id":441,"date":"2010-07-19T14:13:37","date_gmt":"2010-07-19T14:13:37","guid":{"rendered":"https://www.divydovy.com/?p=441"},"modified":"2020-01-23T10:30:14","modified_gmt":"2020-01-23T10:30:14","slug":"wordpress-3-custom-menu-support-in-thematic","status":"publish","type":"post","link":"https://www.divydovy.com/2010/07/wordpress-3-custom-menu-support-in-thematic/","title":{"rendered":"WordPress 3 Custom Menu Support in Thematic"},"content":{"rendered":"<p>More thematic child theme functions goodness 🙂</p>\n<p>Having read the comments on this page: <a href=\"http://themeshaper.com/wordpress-menu-tricks/\">http://themeshaper.com/wordpress-menu-tricks/</a> I couldn&#8217;t find a definitive copy and paste guide &#8211; looks like the HTML and PHP tags were being stripped out. So, leaning heavily on <a title=\"Tony L\" href=\"http://blog.jethro.fi/\">Tony L</a>&#8216;s work (thanks Tony!), here is a copy-paste-edit example. Simply add this to your Thematic child theme&#8217;s functions.php file and you should find that you can then use the &#8216;Menus&#8217; tab under WP&#8217;s Appearance menu in the CMS.</p>\n<p><code><br />\n// Add support for WP3 custom menus<br />\nadd_theme_support( 'nav-menus' );</code></p>\n<p><code> </code></p>\n<p><code>// Remove Thematic default menu<br />\nfunction remove_thematic_menu() {<br />\nremove_action('thematic_header','thematic_access',9);<br />\n}<br />\nadd_action('init','remove_thematic_menu');</p>\n<p>// Register the custom menu with the theme<br />\nfunction register_custom_menu() {<br />\nregister_nav_menu( 'primary-menu', __( 'Primary Menu' ) );<br />\n}<br />\nadd_action( 'init', 'register_custom_menu' );</p>\n<p></code></p>\n<p><code>// Output the new menu to the thematic header<br />\nfunction childtheme_access(){<br />\nwp_nav_menu( array('primary-menu', 'menu_class' =&gt; 'sf-menu' ) );<br />\n}<br />\nadd_action('thematic_header', 'childtheme_access', 4);</code></p>\n<p>Any mistakes, omissions or bugs are my own and I&#8217;d love to hear your feedback in the comments. Thanks for reading 🙂</p>\n<h2>Update</h2>\n<p><a title=\"The Georgian Company\" href=\"http://www.thegeorgiancompany.com/\">George Irwin</a> kindly sent me an improvement on the &#8216;Output the new theme to the thematic header&#8217; function, as follows:</p>\n<p><code><br />\n// Output the new 3.0 menu to the thematic header<br />\nfunction childtheme_access(){?&gt;<br />\n&lt;div id=\"access\"&gt;<br />\n&lt;div class=\"skip-link\"&gt;&lt;a href=\"#content\" title=\"&lt;?php _e('Skip navigation to the content', 'thematic'); ?&gt;\"&gt;&lt;?php _e('Skip to content', 'thematic'); ?&gt;&lt;/a&gt;&lt;/div&gt;<br />\n&lt;?php wp_nav_menu( array('primary-menu', 'menu_class' =&gt; 'sf-menu' ) ); ?&gt;<br />\n&lt;/div&gt;&lt;!-- #access --&gt;<br />\n&lt;?php<br />\n}<br />\nadd_action('thematic_header','childtheme_access',4);<br />\n</code></p>\n<p>As George rightly points out, this keeps the new custom menu in line with the original as defined by Ian Stewart in the Thematic header-extensions.php file so that you don&#8217;t need to change your CSS. Much better George, thanks 🙂</p>\n<h2>Update 2</h2>\n<p>Thanks to <a title=\"skarab\" href=\"http://twitter.com/skarabasakis\">skarab</a> and <a title=\"Manxstef\" href=\"http://stefpause.com/\">Manxstef</a>, there&#8217;s a further improvement to this code 🙂</p>\n<p><code><br />\n// Output the new 3.0 menu to the thematic header<br />\nfunction childtheme_access(){?&gt;<br />\n&lt;div id=\"access\"&gt;<br />\n&lt;div class=\"skip-link\"&gt;&lt;a href=\"#content\" title=\"&lt;?php _e('Skip navigation to the content', 'thematic'); ?&gt;\"&gt;&lt;?php _e('Skip to content', 'thematic'); ?&gt;&lt;/a&gt;&lt;/div&gt;<br />\n&lt;?php wp_nav_menu( array('primary-menu', 'container_class' => 'menu', 'menu_class' => 'sf-menu') ); ?&gt;<br />\n&lt;/div&gt;&lt;!-- #access --&gt;<br />\n&lt;?php<br />\n}<br />\nadd_action('thematic_header','childtheme_access',9);<br />\n</code></p>\n<p>These tweaks ensure that the custom menu is created on the page in exactly the same place and with the same DOM as the default Thematic menus. Thanks both!</p>\n","protected":false},"excerpt":{"rendered":"<p>More thematic child theme functions goodness 🙂 Having read the comments on this page: http://themeshaper.com/wordpress-menu-tricks/ I couldn&#8217;t find a definitive copy and paste guide &#8211; looks like the HTML and PHP tags were being stripped out. So, leaning heavily on Tony L&#8216;s work (thanks Tony!), here is a copy-paste-edit example. Simply add this to your Thematic child theme&#8217;s functions.php file and you should find that you can then use the &#8216;Menus&#8217; tab under WP&#8217;s Appearance menu in the CMS. // Add support for WP3 custom menus add_theme_support( &#8216;nav-menus&#8217; ); // Remove Thematic default menu function remove_thematic_menu() { remove_action(&#8216;thematic_header&#8217;,&#8217;thematic_access&#8217;,9); } add_action(&#8216;init&#8217;,&#8217;remove_thematic_menu&#8217;); [&hellip;]</p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_uag_custom_page_level_css":"","clkt_auto_upload":"0","_clkt_publish_and_upload":false,"_jetpack_memberships_contains_paid_content":false,"activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":3,"activitypub_interaction_policy_quote":"","activitypub_status":"","footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"_wordproof_timestamp":false},"categories":[7],"tags":[181,151,182,180,165,140,125,179],"my_content_publications":[],"class_list":["post-441","type-post","status-publish","format-standard","hentry","category-web","tag-access","tag-child-theme","tag-code-snippets","tag-custom-menu-support","tag-functions","tag-thematic","tag-wordpress","tag-wordpress-3"],"blocksy_meta":{"styles_descriptor":{"styles":{"desktop":"","tablet":"","mobile":""},"google_fonts":[],"version":6}},"clkt_attachments":{"featured_image":null,"inline_attachments":[],"upload_candidates":[],"max_free_size":102400,"max_allowed_size":104857600},"_clkt_upload_mode":"new_only","clkt_content_hash":"63cd3229efeb226a1a75b983652ec0757acf5ad542195d08d28840300107c09d","customFields":{"clkt_auto_upload":"0","activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":3,"activitypub_interaction_policy_quote":"","activitypub_status":"","footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"processed_attachments":{"total_attachments":0,"uploaded_to_arweave":0,"kept_original_urls":0,"upload_summary":{"total":0,"uploaded":0,"failed":0,"too_large":0,"reused":0}}},"paymentAddress":"8_-tV4d15kVVq9Gd-Al2MAIC3LqNtJ_KgFol71TzxPw"}