WordPress Fancybox navigation item

I am currently trying to get one of my top-navigation links to open as iFrame in Fancybox.

I’ve noted there is a way to add a rel item using the Link Relationships (XFN) option in the menu creator which results in my link looking like:

Read More
    <a rel="video" href="http://www.google.com">fancy</a>

However I would require my link to open as:

    <a rel="video" class="fancybox" href="http://www.google.com"></a>

By chance I stumbled upon this solution which suggests to add this to the theme functions.php, although it results in an error:

    function add_menuclass($ulclass) {
    return preg_replace('/<a rel="fancybox"/', '<a rel="fancybox" class="fancybox"', $ulclass, 1);
    }
    add_filter('wp_nav_menu','add_menuclass');

Does anyone know how I can get this properly working? Some advise would be highly appreciated. Thank you very much!

Related posts

Leave a Reply

1 comment