ThemeShaper Forums » Thematic


Thematic Pages Menu & wp_page_menu filter

(11 posts)
  • Started 11 years ago by Monkian
  • Latest reply from helgatheviking
  • This topic is resolved
  1. Hi,

    First; the initial thanks - Thematic is fantastic, and I use it A LOT at work to help with building a decent basic skeleton for a site and a theme. Thanks HUGELY for the work put in on it.

    Now; the issue.

    In the course of building a Page Menu widget I ran into an annoyance that might not yet have occured to the Thematic writers. So I'm putting it forward for consideration.

    Basically its a pain to get wp_page_menu working for you if you're writing a plugin that has to live alongside the Thematic page menu. And I think with minimal effort Thematic could play nicer.

    By filtering wp_page_menu instead of capturing its output and then altering it in the one place really intended, Themtaic renders the core function useless to any other plugin or widget running on the site.

    There's a quiet assumption in the use of that filter that only one page menu call would ever be made on a page; and we know what assumption is the mother of...

    Basically any call to wp_page_menu gets the sf-menu class added to it; which makes that menu render horizontally. You can disable this with a remove_action call, but then you lose the main Thematic menu's rendering all together.

    What I think the goal should be is for the Thematic system to modify the main menu's output, and leave other calls (the hell) alone.

    As far as I can see (in my version, its possible this isn't the very latest), the only call to wp_page_menu in Thematic is in libraries/extensions/header-extensions.php on line 395, where it relies on the filter to add the class. You have basically effected a global change to a core function's output, for your ONE use per page.

    My suggestiuon is that the filter be simply removed, restoring wp_page_menu to being useable as reasonably expected.

    Then instead of line 395:

    <?php wp_page_menu('sort_column=menu_order') ?>


    $thematic_menu = wp_page_menu('sort_column=menu_order&echo=0');
     echo preg_replace('/
    <ul>/', '<ul class="sf-menu">', $thematic_menu, 1);

    So, really, just targetting the ONE instance of the menu you are intending to change, rather than ALL instances, no matter who generates them.

    Posted 11 years ago #
  2. Here's how I get around that issue with the following in functions.php:

    function unhook_thematic_add_menuclass() {
    add_filter('init', 'unhook_thematic_add_menuclass');
    function unhook_thematic_access() {
    function main_nav() {?>
      <div id="access">
        <div class="skip-link"><a href="#content">"><?php _e('Skip to content', 'thematic'); ?></a></div>
      <?php echo preg_replace('/
    <ul>/', '<ul class="sf-menu">', wp_page_menu('sort_column=menu_order&echo=0'), 1);?>
        </div><!-- #access -->

    Then wp_page_menu can be used elsewhere without inheriting the thematic classes and ids, etc.

    Posted 11 years ago #
  3. Hi,

    sorry for this delay .. this issue will be fixed in Thematic Revision 652.


    Posted 11 years ago #
  4. @Chris: Newbie question I'm afraid, but I was wondering if this revision to Thematic will change how we use/modify the menu etc.?

    Posted 11 years ago #
  5. Not really .. the older version filtered the UL class 'sf-menu' into wp_page_menu. This caused every call of wp_page_menu() to include the UL class.

    The new version takes the output of wp_page_menu() and adds the UL class.

    Benefit: All other calls of wp_page_menu() won't include this UL class. Makes the life easier for plugin / widget developers.


    Posted 11 years ago #
  6. @Chris: Thanks for the explanation :)

    Posted 11 years ago #
  7. We've removed 'thematic_access' on 'thematic_header' at priority 9. At priority 10 we've added to 'thematic_header' a simple call to wp_page_menu. This call breaks on recent versions of thematic, and outputs nothing. Any workarounds? My client hit update, and now has no menu.

    Posted 10 years ago #
  8. the problem is thematic completely ignores all args past to wp_page_menu in favor of its own. since whenever thematic_page_menu_args was added. this is why I try to never update thematic. This should be a *filter*. pass-thru should be possible.

    Posted 10 years ago #
  9. adding remove_filter('wp_page_menu_args','thematic_page_menu_args'); to chris' code chunk solved for me.

    Posted 10 years ago #
  10. sorry, steveblamey code chunks

    Posted 10 years ago #
  11. huh? why would you remove thematic_access in the first place? just don't put a custom menu in the "primary" location and it will fall back to wp_page_menu by default. if you are really opposed to the sweetness of custom menus, then there is probably a way to unregister it, but i can't figure that out right now. but if you're using some super outdated version of thematic you might not even have custom menus.

    this works just fine for me in terms of passing args to the page menu

    function childtheme_menu_args($args) {
       $args = array(
           'show_home' => 'Home',
           'echo' => false
    	return $args;

    i commented out the first filter, but i left it b/c it also worked- just uses default WP filter versus the thematic one.

    i'm not 100% sure why i have to maintain the echo=>FALSE; in this filter when it is the new thematic default arg, but there ya go. it doesn't even lose the menu entirely, it just loses the styling as it must not get to the little preg_replace function that adds the sf-class to the page menu UL element.

    the switch from echo=>true to echo=>false was well-documented a year ago when it actually happened. it did cause some issues for a lot of people, and could be contributing to your trouble. i think the new way thematic handles menus is pretty sweet and i've never had an issue w/ it.

    but you should be able to put

    $my_args = array();

    anywhere you like.

    "this is why I try to never update thematic"

    i don't understand this at all. why wouldn't you update? thematic 0.9.8 (which is available here: ) has quite a few improvements and bug fixes. and it is really hard for the limited, volunteer community to provide support on old versions.

    Posted 10 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.