Title: PHP Code being commented out
Last modified: August 4, 2020

---

# PHP Code being commented out

 *  [lpaweb](https://wordpress.org/support/users/lpaweb/)
 * (@lpaweb)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/php-code-being-commented-out/)
 * On the primary menu, i have a sub-menu replaced by a mini-cart function, which
   is being commented out by the html, but it only happens on the homepage. In all
   the other pages, it shows correctly.
 * I’m using the replace option on the mega menu, and i’m replacing with this:
    
   <div class=”widget_shopping_cart_content”><?php woocommerce_mini_cart(); ?></
   div>
 * Thank you in advance.
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fphp-code-being-commented-out%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [megamenu](https://wordpress.org/support/users/megamenu/)
 * (@megamenu)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/php-code-being-commented-out/#post-13211937)
 * Hi lpaweb,
 * I think the fact it loads on the inner pages is a red herring, I think the cart
   contents are being loaded using ajax (because you’ve wrapped it in a div with
   the correct class).
 * You can’t use PHP directly in the replacement options (in general, it’s not possible
   to use PHP like that anywhere in WordPress). Instead, you should create a custom
   shortcode that executes the PHP, then add the shortcode to the menu instead.
 * Alternatively, looking at [this comment for the function](https://docs.woocommerce.com/wc-apidocs/source-function-woocommerce_mini_cart.html#2070),
   it seems like you could just add the WooCommerce Cart widget directly to the 
   sub menu, and that in turn will call ‘woocommerce_mini_cart()’.
 * Regards,
    Tom
 *  Thread Starter [lpaweb](https://wordpress.org/support/users/lpaweb/)
 * (@lpaweb)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/php-code-being-commented-out/#post-13212263)
 * Hi Tom,
 * Thank you for your reply.
    The thing is, it works in all other pages the way 
   it is now. It just doesn’t work on the Homepage.
 * Regards.
 *  Plugin Author [megamenu](https://wordpress.org/support/users/megamenu/)
 * (@megamenu)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/php-code-being-commented-out/#post-13212411)
 * Hi lpaweb,
 * I understand that, I’m not sure why (we don’t control the contents of the widgets,
   we let the widgets control themselves) but can you try with the Widget instead
   just to see if it works?
 * Regards,
    Tom

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘PHP Code being commented out’ is closed to new replies.

 * ![](https://ps.w.org/megamenu/assets/icon-128x128.png?rev=1489843)
 * [Max Mega Menu](https://wordpress.org/plugins/megamenu/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/megamenu/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/megamenu/)
 * [Active Topics](https://wordpress.org/support/plugin/megamenu/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/megamenu/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/megamenu/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [megamenu](https://wordpress.org/support/users/megamenu/)
 * Last activity: [5 years, 10 months ago](https://wordpress.org/support/topic/php-code-being-commented-out/#post-13212411)
 * Status: not resolved