Forum Replies Created

Viewing 10 replies - 61 through 70 (of 70 total)
  • Hey becskr –

    I’ve got valid html with that code at the toomai link above. Do you have a link to your implementation?

    I agree – it would be best to just have one level of unordered list rendered… but we’re hacking at the menu walker code that would normally show the top level and secondary menu items to just show the secondary level – so I’m not sure if/how that’s possible…

    Dag – automated code-chunk removal – that’s new!
    New Function here:
    https://wordpress.pastebin.com/Jk7n20mB

    UPDATE:
    This version of the function fixes the missing <li> and integrates 5ulo’s bug fix.

    1) Put this in your functions.php file:

    [Code moderated as per the Forum Rules. Please use the pastebin]

    2) Put this in your theme file, like sidebar.php or wherever else you might want to put your submenu:

    $menu_args = array(
      'walker'          => new Custom_Walker_Nav_Sub_Menu(),
      'container'       => '',
      'menu_class'      => 'sister-pages',
    );
    wp_nav_menu($menu_args);

    3) Make sure you have some custom CSS to style it all up.

    Also note that with the new menu system you can add multiple instances of a single page the the menu. That’s very handy – for example I’ve added a top level menu item “About” to this menu, and then added “About” again as its first subpage, but renamed the link “About the Quintet”.
    https://toomaiquintet.com/bios/

    Fun times with menus!

    This is so close to being perfect – check out my implementation of the above code here:
    https://toomaiquintet.com/bios/

    Only one tiny little problem:

    <ul id="menu-menu-1" class="sister-pages">
    <ul class="sub-menu">
    	<li ...
    	<li ...
    </ul>
    </li>
    </ul>

    Anyone know how to add <li> after <ul id="menu-menu-1" class="sister-pages"> using this custom walker code? Not a huge deal – it still works as is, but it would be nice to have proper HTML.

    I’m using sushicoder’s original solution, as posted by petersom3000, with nerdfactor’s revision to eliminate the parent item.
    Works like a charm. THANK YOU to everyone who helped with this…

    Just to sum it all up:

    1) Put this in your functions.php file:

    [Code moderated as per the Forum Rules. Please use the pastebin]

    awesome – thanks 2is3!

    here’s my menu for the header – works nicely up to two levels of page depth (so children / grandchildren)

    i’m sure there’s a more efficient way to do this – but this works.

    <?php
    $current = $post->ID;
    $parent = $post->post_parent;
    $haschildren = wp_list_pages("depth=1&amp;title_li=&amp;child_of=".$current."&amp;echo=0");
    $grandparent_get = get_post($parent);
    $grandparent = $grandparent_get->post_parent;
    
    if ($grandparent != 0) {
      if ($grandparent) {
      $grandchildren = wp_list_pages("depth=1&amp;title_li=&amp;child_of=".$grandparent."&amp;echo=0");
      }
      else {
      $grandchildren = wp_list_pages("depth=1&amp;title_li=&amp;child_of=".$grandparent."&amp;echo=0");
      }
      if ($grandchildren &amp;&amp; is_page()) { ?>
    <div class="submenu">
      <ul class="submenuul">
      <?php echo $grandchildren; ?>
      </ul>
    </div>
    <?php }
    }
    
      if ($parent) {
      $children = wp_list_pages("depth=1&amp;title_li=&amp;child_of=".$parent."&amp;echo=0");
      }
      else {
      $children = wp_list_pages("depth=1&amp;title_li=&amp;child_of=".$current."&amp;echo=0");
      }
      if ($children &amp;&amp; is_page()) { ?>
    <div class="submenu">
      <ul class="submenuul">
      <?php echo $children; ?>
      </ul>
    </div>
    <?php }
    
    if ($haschildren != '' &amp;&amp; $parent != '0' &amp;&amp; $grandparent == '0') {
      $morechildren = wp_list_pages("depth=1&amp;title_li=&amp;child_of=".$current."&amp;echo=0");
      }
      if ($morechildren &amp;&amp; is_page()) { ?>
    <div class="submenu">
      <ul class="submenuul">
      <?php echo $morechildren; ?>
      </ul>
    </div>
    <?php }
    ?>

    You could also put some js that will forward to a success page in that same spot in contact-form-7.js if you wanted to do that…

    This is a temporary hack that I did ’cause I have a very long form.

    hide the form on success – it’s confusing if the empty form is still there, especially if it’s taller than one screen.

    open contact-form-7.js
    under line 90 ( if (1 == data.mailSent) )
    add

    var wpcfTheForm = document.getElementById('wpcf7-formid');
    wpcfTheForm.style.display = ('none');

    Then add that id to the form
    Open wp-contact-form-7.php – line 914

    $form .= '<form action="' . $url . '" method="post" id="wpcf7-formid" class="wpcf7-form"' . $enctype . '>';

    A few nice little hacks I just make for this:
    Keep in mind these are dirty-tick hacks that you will have to do over if you upgrade, and might just break everything if you don’t have some idea what you’re doing….

    1) you can put your custom HTML for your success message here:

    wp-contact-form-7.php line 143
    $echo = '{ mailSent: 1, message: "' . js_escape($this->message($cf, 'mail_sent_ok')) . '", ...

    becomes
    $echo = '{ mailSent: 1, message: "<div>your html here - use escape chars!!</div>", ...

    Don’t forget, now your admin panel field does nothing…

    =======================

    2) contact-form-7.js
    hide the form on success – it’s confusing if the empty form is still there, especially if it’s taller than one screen.

    under line 90 ( if (1 == data.mailSent) )
    add

    var wpcfTheForm = document.getElementById('wpcf7-formid');
    wpcfTheForm.style.display = ('none');

    Then add that id to the form – line 914 in wp-contact-form-7.php
    $form .= '<form action="' . $url . '" method="post" id="wpcf7-formid" class="wpcf7-form"' . $enctype . '>';

Viewing 10 replies - 61 through 70 (of 70 total)