Page 3 of 3 FirstFirst 123
Results 21 to 23 of 23

Thread: wp_page_menu issues

  1. #21
    Otto's Avatar
    Otto is offline On The Rocks
    Join Date
    Apr 2009
    Location
    Memphis, TN
    Posts
    865

    Default

    Looking at that code, I'd say that you should rework it into this:


    PHP Code:
    function bns_menu($menu$args) {
        if (
    is_home() || is_front_page()) {
    $args['echo'] = false;
       
    $args['depth'] = 1;
       
    remove_filter('wp_page_menu','bns_menu',10,2);
       
    $menu wp_page_menu($args);
          }
      return 
    $menu

    With this in the header:

    PHP Code:
    <? wp_page_menu('depth=1'); ?>
    Why? Speed. With your code, you are forcing the page menu to generate twice on every page load. With mine, it only has to do that on the front page, other pages don't have to generate the page menu but once.


    And honestly, your original solution was fine for a one-off. The only real reason to do something like this is if you want to make it easily configurable through a settings menu or put it in a plugin or something. If it's only for one site, and you're not releasing something with this code in it, then your original way is fastest, cleanest, and simplest. I was really only using your code as an example of how the filter worked, not to suggest a "right" way or anything.



  2. #22
    Cais's Avatar
    Cais is offline Big Tipper
    Join Date
    Feb 2009
    Location
    Mississauga, ON, CANADA
    Posts
    349

    Default

    I'm looking for the happy median between the fast, clean, and simple model to the fully configurable model. I try to design all my new themes under the premise they will be released to the Themes repository; "one-offs" I create as a child theme.

    (iPhone browsing does have its limitations ... I have to wait until I'm at my desktops to really look at this.)

    @Otto - I appreciate your using my code as an example, I'd still be stumblingabout without your sample to start with. Thx!

  3. #23
    Cais's Avatar
    Cais is offline Big Tipper
    Join Date
    Feb 2009
    Location
    Mississauga, ON, CANADA
    Posts
    349

    Default

    I think it's finally sinking in ...

    You write the "header" code for the more generic page loads; and, write the "function" code for the exceptions.

    Of course, these examples may only be applicable to the theme ideas I am working with, as it is really just my preference to not have a "Home" link on the front page, but to have it on any other page.

    So ... to carry forward with the last "speedy" example, I would likely use in the header file:
    PHP Code:
    <?php wp_page_menu('show_home=true&depth=1'); ?>
    ... it may still need testing (later), but it makes sense to me as I write this.

    PS: The new theme is not too far off, just have to finish some graphics and tidy up the CSS ... and implement this new menu code
    Last edited by Cais; 07-31-2009 at 05:52 PM.

Page 3 of 3 FirstFirst 123

LinkBacks (?)

  1. 07-14-2009, 09:12 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •