I want to add a custom menu item to the main navigation menu, On clicking this item I want to open a lightbox form. I have the form-shortcode ready to be placed but on a page but I don't know how to do this in the main navigation menu, i have used cforms-II for the form and lightbox form to display it in lightbox modal. please help. i'm using wordpress 3.5 Note: I may need to change my theme in recent future so I would like the solution to programtically do this.Thanks. Edit: I'm trying to use the following code: add_filter() to add menu item, and for light box form i have this code:

add_filter( 'wp_nav_menu_items', 'my_custom_menu_item', 10, 2 );

function my_custom_menu_item ( $items, $args ) {
    if (is_single() && $args->theme_location == 'primary') {
        $items .= '<li>Show whatever</li>';
    return $items;

[formlightbox_call title="Get free quote" class="4"]here[/formlightbox_call]
[formlightbox_obj id="4" style="padding: 10px; width:350px"][contact-form-7 id="848" title="Contact form 1"][/formlightbox_obj]
  • Show us what code you are working with, tell us more about the lightbox script you are working with too. It might be as simple as assigning a custom class to your menu item or it might require that you dig deeper into the use of wp_nav_menu and possible use a custom nav menu walker function. – Adam Feb 19 '13 at 6:44

Try this.


Dashboard -> Appearance -> Menus -> screen options (See top corner) -> Check css classes -> Now add a custom class in your link ( Ex: lightboxlink )

Now add some jquery code in the footer like

$(document).ready(function() {
$(".lightboxlink").click(function() {
  • Just to point out, typically, you want to add the link value as "#lightbox_content" or whatnot, and output your lightbox'd content in wp_footer (with display none container around the div with the id="lightbox_content"). – WraithKenny Sep 23 '13 at 20:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.