Hi, you could try something like this in a PHP file (but it depends on where/how it is used!):
<a href="#contact_form_pop" class="fancybox-inline">Contact Us</a>
<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="87" title="Contact form 1"]'); ?>
</div>
</div>
Maybe tell a bit more about where you want to use the popup or which theme file you wish to edit?
Thanks for your response! @ravanh
Basically trying to create a button/link for the a contact form. Location could just be like in index.php, footer.php, etc.
But I need it to work with my own href URL because my URL has specific parameters that pre-populates certain fields of the contact form.
eg. of my href URL:
<a href="/contact-support/?topic=topic_story&story_url=<?php the_permalink();?>"><img src="/btn_image">
Is this possible?
The problem I see is that of an inline popup (with contact form or anything else) to work, that content must be present (hidden or not) on the page itself. Hence the “inline” in the title.
If you wish to embed a contact form that in on another page, like /contact-support/ in your case, then you will need to use the “iFrame” option. Activate that on Settings > Media and adapt your code like this in your theme template:
<a href="/contact-support/?topic=topic_story&story_url=<?php the_permalink();?>" class="fancybox-iframe"><img src="/btn_image" /></a>
The only thing to realize is: this will open the complete contact support page in a light box, meaning that it will have header, sidebars and footer also. This can be prevented with another plugin “Show content only” but you’ll have to see if that plugin is still maintained.
Thanks for the input. I might have to try a separate way then. This plugin doesn’t seem like a viable solution. Appreciate your help! Thanks again. @ravanh
@ravanh Just trying to revisit this solution.
I understand what you mean by showing the content only. But is this a plugin that’s supposed to work with FancyBox? Could you kindly give an example? Can’t seem to find a “show content only” plugin.
Hi, that plugin is https://wordpress.org/plugins/show-content-only/ but it looks like it has been abandoned so I cannot tell you if it still works or not…
An alternative would be a create a custom theme template that does not include the usual get_sidebar() stuff and only has the bare minimum (post title and content). Some themes already include such a template, often called “landing page” or “content only”.
If you have such a template to choose from in your page editor, then use that template for your contact page.