squarecandy
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: wp_nav_menu: List only 2nd level (separate submenu)?Forum: Fixing WordPress
In reply to: wp_nav_menu: List only 2nd level (separate submenu)?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…
Forum: Fixing WordPress
In reply to: wp_nav_menu: List only 2nd level (separate submenu)?Dag – automated code-chunk removal – that’s new!
New Function here:
https://wordpress.pastebin.com/Jk7n20mBForum: Fixing WordPress
In reply to: wp_nav_menu: List only 2nd level (separate submenu)?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!
Forum: Fixing WordPress
In reply to: wp_nav_menu: List only 2nd level (separate submenu)?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.Forum: Fixing WordPress
In reply to: wp_nav_menu: List only 2nd level (separate submenu)?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]
Forum: Fixing WordPress
In reply to: How to get grandparent page in classes.php?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&title_li=&child_of=".$current."&echo=0"); $grandparent_get = get_post($parent); $grandparent = $grandparent_get->post_parent; if ($grandparent != 0) { if ($grandparent) { $grandchildren = wp_list_pages("depth=1&title_li=&child_of=".$grandparent."&echo=0"); } else { $grandchildren = wp_list_pages("depth=1&title_li=&child_of=".$grandparent."&echo=0"); } if ($grandchildren && is_page()) { ?> <div class="submenu"> <ul class="submenuul"> <?php echo $grandchildren; ?> </ul> </div> <?php } } if ($parent) { $children = wp_list_pages("depth=1&title_li=&child_of=".$parent."&echo=0"); } else { $children = wp_list_pages("depth=1&title_li=&child_of=".$current."&echo=0"); } if ($children && is_page()) { ?> <div class="submenu"> <ul class="submenuul"> <?php echo $children; ?> </ul> </div> <?php } if ($haschildren != '' && $parent != '0' && $grandparent == '0') { $morechildren = wp_list_pages("depth=1&title_li=&child_of=".$current."&echo=0"); } if ($morechildren && is_page()) { ?> <div class="submenu"> <ul class="submenuul"> <?php echo $morechildren; ?> </ul> </div> <?php } ?>
Forum: Fixing WordPress
In reply to: [Plugin: Contact Form 7] Success Page ForwardingYou 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…
Forum: Fixing WordPress
In reply to: [Plugin: Contact Form 7] Success Page ForwardingThis 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) )
addvar 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 . '>';
Forum: Plugins
In reply to: Contact Form 7 – forward success page or link in success messageA 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)
)
addvar 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 . '>';