Title: added code but not working
Last modified: August 30, 2016

---

# added code but not working

 *  Resolved [ameey](https://wordpress.org/support/users/ameey/)
 * (@ameey)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/added-code-but-not-working/)
 * I’m using BizChatBox and added it’s javascript snippet to the code field when
   editing the snippet in your plugin. It’s not working. I thought it was a simple
   cut and paste? What am I missing here?
 * Thanks.
 * [https://wordpress.org/plugins/code-snippets/](https://wordpress.org/plugins/code-snippets/)

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

 *  [raquelglara](https://wordpress.org/support/users/raquelglara/)
 * (@raquelglara)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/added-code-but-not-working/#post-6430413)
 * I’ve got the same problem. I’ve added the code to modify the checkout woocommerce
   form (I want to remove some fields) but it doesn’t work.
 * Could you please help me?
 * Thanks a lot!
 *  Plugin Author [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * (@bungeshea)
 * [10 years, 9 months ago](https://wordpress.org/support/topic/added-code-but-not-working/#post-6430414)
 * Keep in mind that Code Snippets only works with PHP code like you’d find in plugins.
   It doesn’t support raw HTML, CSS or JavaScript code (though there are ways to
   use them).
 * If there’s an issue with code not working at all, generally it’s due to an issue
   in the code, not the plugin.
 *  [Ladyfyre](https://wordpress.org/support/users/ladyfyre/)
 * (@ladyfyre)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/added-code-but-not-working/#post-6430429)
 * Hi, I’m having the same problem, this is what I’m trying to get to work so that
   the breadcrumbs are not displayed on the main shop page of woocommerce.
 *     ```
       function my_woocommerce_custom_breadcrumbs() {
           if(is_shop()){
           remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0);
           }
       }
       add_filter('woocommerce_before_main_content','my_woocommerce_custom_breadcrumbs');
       ```
   
 *  [Terence Milbourn](https://wordpress.org/support/users/pubdirltd/)
 * (@pubdirltd)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/added-code-but-not-working/#post-6430430)
 * I have a similar problem Shea. If I put this snippet in the plugin it doesn’t
   work, but if I put it into my theme’s functions.php it works fine.
 *     ```
       // Remove the shortcode that's automatically added before the content
       remove_filter( 'the_content', array( $post_series_manager, 'post_series_before' ) );
       ```
   
 *  Plugin Author [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * (@bungeshea)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/added-code-but-not-working/#post-6430431)
 * `remove_filter()` doesn’t work unless it is used correctly. It needs to be called
   _after_ the filter has been added, but _before_ it is called. The discrepancy
   between snippets and functions.php is because snippets run at an earlier hook
   than functions.php.
 * **Ladyfye:**
 * Your example doesn’t work because you’re trying to remove the filter _in the 
   filter hook itself_. This is too late to remove the filter, as it is already 
   running. Try changing the action the wrapper function is hooked to:
 *     ```
       function my_woocommerce_custom_breadcrumbs() {
           if ( is_shop() ) {
               remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0);
           }
       }
       add_action('woocommerce_loaded','my_woocommerce_custom_breadcrumbs');
       ```
   
 * **Terence:**
 * I think the issue here is that you’re trying to remove a filter before is has
   been registered. Try wrapping it in a later hook:
 *     ```
       add_action( 'init', function () {
       	global $post_series_manager;
       	// Remove the shortcode that's automatically added before the content
       	remove_filter( 'the_content', array( $post_series_manager, 'post_series_before' ) );
       } );
       ```
   
 * It could also be an issue to do with access to the `$post_series_manager` variable.
 *  [mas6ce](https://wordpress.org/support/users/mas6ce/)
 * (@mas6ce)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/added-code-but-not-working/#post-6430432)
 * Hi! I’m trying to remove the “add to cart” button and display a different message
   for some customers (depending on badges through myCred) and have the normal add-
   to-cart option for others. I wrote this code and the plugin doesn’t object to
   any syntax, but it is not working. I really appreciate any help with this – thank
   you!!
 *     ```
       // this keeps the site from crashing if badges are disabled
       if (function_exists ('mycred_get_users_badges')){
   
         // get a variable for the badge of the user
         // *note: this only works if badges are only used for purchasing myCred and reset after each purchase!
         $this->load->database();
         class mycred;
         $mycred = new mycred;
       	$userPurchasedCultureCoinsQuestion = $this->$mycred->get_users_badges ($user_id);
   
         // get users' user ID
         	$user_id = pb_displayed_user_id();
   
         // text for purchase button if user has a badge/cannot purchase
       	if ( ($userPurchasedCultureCoinsQuestion == 0)) {
       	  function remove_loop_button(){
       		remove_action ('woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10);
       		remove_action ('woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30);
       		add_action ('init', 'remove_loop_button');
       		add_action (echo "sorry, you don't have enough earned Culture Coins to purchase");
       	  }
   
       }
       ```
   
 *  Plugin Author [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * (@bungeshea)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/added-code-but-not-working/#post-6430437)
 * **mas6ce**:
 * My apologies, but I don’t really use Woocommerce (if that is what you’re using)
   and I wouldn’t know how to write code to work with it without a lot of research.
   Perhaps you’re better off posting this question on a forum specific to that plugin?
 * Also, I would prefer it if you could start a new thread if you have an issue 
   to do with Code Snippets instead of adding onto an existing thread.
 *  [mas6ce](https://wordpress.org/support/users/mas6ce/)
 * (@mas6ce)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/added-code-but-not-working/#post-6430438)
 * Okay thanks for replying!

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

The topic ‘added code but not working’ is closed to new replies.

 * ![](https://ps.w.org/code-snippets/assets/icon.svg?rev=2148878)
 * [Code Snippets](https://wordpress.org/plugins/code-snippets/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/code-snippets/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/code-snippets/)
 * [Active Topics](https://wordpress.org/support/plugin/code-snippets/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/code-snippets/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/code-snippets/reviews/)

 * 8 replies
 * 6 participants
 * Last reply from: [mas6ce](https://wordpress.org/support/users/mas6ce/)
 * Last activity: [10 years, 5 months ago](https://wordpress.org/support/topic/added-code-but-not-working/#post-6430438)
 * Status: resolved