Jump to content

Adding a short code form in WooCommerce Category pages only


GBO
Go to solution Solved by maxxd,

Recommended Posts

Hello

This forum has been a great help in the past. 

I have another query.

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 here:

https://www.offershubdirect.com/product-category/parts-services/

However, using the above code also makes the form appear at the bottom of the product pages (https://www.offershubdirect.com/product/2370-9085-terex-pegson-1412-blow-bar-hammers-chrome/) - no surprise here. How do I prevent the form from appearing on the product pages?

Any help or guidance is appreciated.

Gary

 

 

php contact form.PNG

php contact form2.PNG

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.