I know, that I promised not to break existing child themes with future versions of Thematic. But sometimes it is necessary to break things ’cause we need to fix others.
With the last revision I fixed an issue, where wp_page_menu() got the class sf-menu permanently. Plugin and Widget Developers suffered from headaches because of that. To get rid of this issue I had to change the way Thematic called wp_page_menu().
The old call:
wp_page_menu('sort_column=menu_order')
And the new call:
echo thematic_add_menuclass(wp_page_menu(thematic_page_menu_args()));
The parameter echo changed from TRUE to FALSE.
If you use the standard procedure as described in the sample child theme to add a ‘Home’-link to your menu, your menu will come up without any styling. To fix this behavior you need to remove the parameter echo from your function. It should look like this to work with the latest SVN revision:
function childtheme_menu_args($args) {
$args = array(
'show_home' => 'Home',
'sort_column' => 'menu_order',
'menu_class' => 'menu',
'echo' => false
);
return $args;
}
add_filter('wp_page_menu_args','childtheme_menu_args', 20);
If you use wp_page_menu() in other locations than the header and you need Superfish, make sure that you use the above mentioned call
echo thematic_add_menuclass(wp_page_menu(thematic_page_menu_args()));
11 Comments
thanks for the head’s up, Chris!
I am using version .9.6.1 of Thematic ( I haven’t really figured out SVN yet), so would this be an issue for me?
I’ve noted the change to echo, but as I use the wp_page_menu twice in my functions, can you let me know what changes I may have to make, if any?
relevant code:
// Adds a home link to your menu
// http://codex.wordpress.org/Template_Tags/wp_page_menu
function childtheme_menu_args($args) {
$args = array(
'show_home' => 'Home',
'sort_column' => 'menu_order',
'menu_class' => 'menu',
'echo' => true
);
return $args;
}
add_filter('wp_page_menu_args','childtheme_menu_args');
//add links to the menu
function child_add_menu_items($output) {
$my_code = 'Question EverythingThe Shelf';
return str_replace('',$my_code, $output);
}
add_filter('wp_page_menu','child_add_menu_items');
I haven’t noticed any difference to my theme yet, nothing appears to be broken….but it’s coming, isn’t it
Thanks in advance for any help you can offer!
Yes .. it will come
I guess, that both menus are Superfish styled. In this case you need to integrate the changed
childtheme_menu_args().If you could post your second
wp_page_menu()call, I can tell you what needs to be changed-Thanks for this Chris. Had me stumped for a little while after I updated a site – glad I came across this. Cheers!
Just wanted to say: LOVE the new theme you’ve got here for Thematic 4 You, Chris!
man i was racking my brain trying to figure out where that ul class disappeared to until i remember you’d written a post about breaking something in thematic. much relief. how is the approval going w/ getting the new version into WP?
add_filter(‘wp_page_menu_args’,'childtheme_menu_args’, 20);
have a look at the priority 20 !!!
Thanks!
Chris,
Thanks for the new version of Thematic. Just installed it and it broke the menu on my child theme, but I was able to find the solution in this blog post. I had filtered out some of the pages and when I upgraded, my code in functions.php was no longer filtering out some links.
Thanks again!
Hi Chris, just updated to Thematic version 0.9.7.7. I got my website running in dev with some minor CSS fixes, but the second level of my menu has dissapeared. I went through various threads on the Thematic forum, but can’t figure out how to solve my specific problem.
@Chris
Thanks for a terrific theme, I just want to bring something to your attention…
If you’re monitoring your PHP error logs, you’ll see that your filter code snippet throws 2 exceptions:
[8: Notice] Undefined index: link_before [...]\wp-includes\post-template.php Line: 845 and[8: Notice] Undefined index: link_after [...]\wp-includes\post-template.php Line: 845
This is because the filter completely replaces the original $args array. Two ways to deal with this…
1) Quick n Dirty: append this to the child’s $args array –
,'link_before'=>'','link_after'=>''The empty strings are WordPress’ defaults, and may or may not match the actual runtime values (and you might not care, but you should).
2) Probably more ‘proper’ and likely more future-proof is to merge our options into the inbound array using the WP core’s wp_parse_args(), thus:
function childtheme_menu_args( $args ) {
$my_args = array(
'show_home' => 'Home',
'sort_column' => 'menu_order',
'menu_class' => 'menu',
'echo' => false
);
return wp_parse_args( $my_args, $args );
}
add_filter('wp_page_menu_args','childtheme_menu_args', 20);
which works for me, running PHP 5.2.6 + WP 3.0.2 + Thematic .9.7.7.
And yes, the parameter order for
wp_parse_args()is indeed counter-intuitive.HTH
hi JeffM,
!!
great…that works….wp_parse_args()
thanx