I'm looking to add a contact form to appear under the contents of the WooCommerce Category pages only - not to appear in the product pages. I'm using the following code to display the form:
add_action( 'woocommerce_after_main_content', function(){
// Title
$header = "<br><b>Contact Us</b><br>";
// Message
$text = "<p>Please do not hesitate to contact us with queries you may have</p><br>";
// WPForms shortcode
$wpforms_shortcode = do_shortcode('[wpforms id="1385"]');
// Output combined message and form
echo '
' . $header .'
' . $text .'
' . $wpforms_shortcode .'
';
}, 9 );
The result can be viewed by following this link.
However, using the above code also makes the form appear at the bottom of the product pages - no surprise here.
How do I prevent the form from appearing at the bottom of the product pages?
I added the code and as expected saw the contact form at the bottom of all the shop pages. I need the form to only appear in the category pages.
To display your code output only in product category archives (pages) use the following:
Code goes in functions.php file of your child theme (or in a plugin). Tested and works.