RE my last post, getting Colorbox to work on links in the Custom Menu, I came across another person who wanted the same for Fancybox, SO, thanks to HahahaComedy & his/her code (added in functions.php):
function add_menuclass($ulclass) {
return preg_replace('/<a rel="fancybox"/', '<a rel="fancybox" class="fancybox"', $ulclass, 1);
}
add_filter('wp_nav_menu','add_menuclass');
I did:
function add_menuclass($ulclass) {
return preg_replace('/<a rel="colorbox-link"/', '<a class="colorbox-link cboxElement"', $ulclass, 1);
}
add_filter('wp_nav_menu','add_menuclass');
After editing the functions, in Dashboard/Appearance/Menus, in the screen options tab up top, make sure the Link Relationship XFN is ticked. In Custom Menu involved, in the Link Relationship XFN field I added colorbox-link
This becomes class="colorbox-link" WITHIN the anchor <a /a>, where it'needed, not with the li tags.
It WORKS fine, just not sure it's perfectly written/executed. Also, if I add a Title in the title field in Menu Setup, it stops working, so for now, I live without having the title in the ColorBox.
Anyone confirm this is good code? Fix it perfectly? Make it so the title field doesn't break the link?
Anyway, for now, I'm happy to have it working at all.
Cheers,
Kevin
Original post RE FancyBox: