WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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]
share|improve this question
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. – userabuser 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() {
share|improve this answer
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 posting your answer, you agree to the privacy policy and terms of service.

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