• ektam12

    (@ektam12)


    Hello,

    I want a contact from 7 to open on click from a menu item
    On the menu item, I have added #contact_form_pop in the url field. Added the class “fancybox-inline” and then added this to my header-
    <div style=”display:none” class=”fancybox-hidden”>
    <div id=”contact_form_pop” class=”hentry” style=”width:460px;max-width:100%;”>
    <?php echo do_shortcode[contact-form-7 id=”1396″ title=”Contact form 1″]?>
    </div>
    </div>
    But all I am getting is a blank box. What is the problem?

    Thanks

Viewing 9 replies - 1 through 9 (of 9 total)
  • Hi @ektam12 the PHP call seems to be missing some parentheses and quotes. Change it to:

    
    <?php echo do_shortcode('[contact-form-7 id="1396" title="Contact form 1"]'); ?>
    
    Thread Starter ektam12

    (@ektam12)

    Hello,

    Thanks for you reply. But it still shows me an empty box. I checked the console too but there are no errors. Am I placing the code in the wrong file? Where exactly I have to add this?

    ALso, I tried adding the following in functions.php but to no avail, I get an error that the Requested content cannot be loaded.

    <?php function custom_content_after_body_open_tag() {

    ?>

    <div style=”display:none” class=”fancybox-hidden”>
    <div id=”contact_form_pop” class=”hentry” style=”width:460px;max-width:100%;”>
    <?php echo do_shortcode(‘[contact-form-7 id=”1396″ title=”Contact form 1″]’); ?>
    </div>
    </div>

    <?php

    }

    add_action(‘after_body_open_tag’, ‘custom_content_after_body_open_tag’); ?>

    There is no action hook after_body_open_tag in the default theme but in yours there might be. Which theme are you using?

    A link to your site might help, so I check you if your form and hidden is present in the page source at all.

    Thread Starter ektam12

    (@ektam12)

    Its newkey.co.in

    I am trying it on the main menu- add listing menu item.
    Website is still under construction

    Thanks

    Ok, thanks. The contact form code is indeed not present in your page source. Try this:

    
    add_action(‘wp_footer’, ‘custom_content_after_body_open_tag’);
    

    OR you could simply paste this code in a HTML Widget in the footer:

    
    <div style="display:none" class="fancybox-hidden">
    <div id="contact_form_pop" class="hentry" style="width:460px;max-width:100%;">
    [contact-form-7 id="1396" title="Contact form 1"]
    </div>
    </div>
    

    In this case you do not need to add any code to your theme’s functions.php file…

    Thread Starter ektam12

    (@ektam12)

    Sorry to bother you again.
    I have removed the code from functions.php and just added the html in the footer widget, but it still shows the same error.

    Just wanted to make sure that fancybox-inline is the correct class name which I have used for the menu item.

    Thanks

    Thread Starter ektam12

    (@ektam12)

    Okay. When I am adding the html in the widget, it is not working, but on adding the code on the page it is.

    Thread Starter ektam12

    (@ektam12)

    Adding the html in the header/footer section, just displays the shortcode. On the home page as there is html added, it is working fine but on the internal pages only the shortcode displays

    Adding the html in the header/footer section, just displays the shortcode.

    Ah, you may solve this by adding this to your functions.php:

    
    add_filter( 'widget_text', 'do_shortcode' );
    
Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Trying to open contact form 7 from menu item in a pop up’ is closed to new replies.