Title: Code conflict
Last modified: January 17, 2020

---

# Code conflict

 *  Resolved [callaloo](https://wordpress.org/support/users/callaloo/)
 * (@callaloo)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/code-conflict-3/)
 * Hi. I have incorporated this plugin’s SVGs extensively throughout my site. But
   the first code is preventing the second from showing the icons sitewide except
   on posts. Is there a way to resolve this conflict?
 * **Code 1**\
    }
 *     ```
       // Scriptless social sharing buttons before and after content
       add_action( 'generate_before_content', 'my_share_buttons');
       add_action( 'generate_after_content', 'my_share_buttons');
       function my_share_buttons() {
           if ( is_single() ) {
               echo do_shortcode( '[scriptless]' );
           }
       }
       ```
   
 * **Code 2**
 *     ```
       //Show scriptless buttons on archive pages
       add_filter( 'scriptlesssocialsharing_can_do_buttons', 'prefix_add_buttons_archives' );
       function prefix_add_buttons_archives( $cando ) {
           if (is_home() || is_tax() || is_category() || is_404() ) {
               $cando = true;
           }
           return $cando;
       }
       ```
   
 * Theme is GeneratePress free version.

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

 *  Plugin Author [Robin Cornett](https://wordpress.org/support/users/littlerchicken/)
 * (@littlerchicken)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/code-conflict-3/#post-12336643)
 * My guess is that you do not have any selections made for the Button Location 
   settings, because you are wanting to use the shortcode. In that case, it’s not
   a conflict between your two functions, necessarily; it’s more that the first 
   one is incomplete because it is running only when `is_single()` is true, and 
   if the locations are disabled, then the plugin would be expecting you to handle
   this manually. I would suggest modifying your first function to be more in line
   with your second, something like this:
 *     ```
       add_action( 'generate_before_content', 'my_share_buttons' );
       add_action( 'generate_after_content', 'my_share_buttons' );
       function my_share_buttons() {
       	if ( is_single() || is_home() || is_tax() || is_category() || is_404() ) {
       		echo do_shortcode( '[scriptless]' );
       	}
       }
       ```
   
 * You may need to have “Manual” checked for the button locations as the stylesheet
   may not print with the buttons outside of the content (this is due to an error
   which will be resolved in the next release).
 *  Thread Starter [callaloo](https://wordpress.org/support/users/callaloo/)
 * (@callaloo)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/code-conflict-3/#post-12337007)
 * I selected the manual location in the plugin settings before using the shortcode.
   I use the hooks before and after content because the default hooks you use makes
   the buttons’ text to appear inside my schema body text. I like how you use the
   IDs and the shorter SVG links and that’s why I use them. Or could you suggest
   a way for me to use the SVG sprite for my custom links independent of the plugin?(
   In the meantime, I have used your provided code but hidden all buttons except
   on single posts with `display:none`. However, I am looking for a solution to 
   only load the icons used on a particular page, archive, taX, etc)
 *  Plugin Author [Robin Cornett](https://wordpress.org/support/users/littlerchicken/)
 * (@littlerchicken)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/code-conflict-3/#post-12337138)
 * Okay, can you clarify what it is that you are trying to accomplish? I thought
   you wanted buttons on archive, 404, and single posts, but if you are hiding buttons
   on single posts, then obviously I am misunderstanding.
 * Note: you can change the target of the Before/After Content locations to your
   specific theme hooks using the [code example in the FAQ](https://wordpress.org/plugins/scriptless-social-sharing/#what%20if%20i%20want%20to%20move%20where%20the%20buttons%20are%20output%3F),
   instead of echoing out the shortcode. Either way works, though.
 *  Thread Starter [callaloo](https://wordpress.org/support/users/callaloo/)
 * (@callaloo)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/code-conflict-3/#post-12337178)
 * What I mean is I use the SVG icons from your plugin for my custom links (e.g.
   social icons, etc) instead of using other SVG icons. So, I was using the code
   to show your links in archives, 404 page, etc so that these icons could show 
   up (e.g I use some of them in my sidebar to my Facebook and Twitter pages and
   Reddit profile). I call each SVG in this format for example, <`svg class="scriptlesssocialsharing__icon
   facebook" role="img" aria-hidden="true"> <use href="#facebook-square" xlink:href
   ="#facebook-square"></use></svg>`. I am also using a stripped-down version of
   the brands.svg which I am calling from my custom plugin’s folder so that only
   the square icons load (and I only use those). But it seems this plugin’s SVG 
   icons cannot load unless the buttons are declared to show on other areas of the
   site except single posts. I was looking to bypass this and only load the icons
   anywhere on the site without limiting them on where the buttons are output (single
   posts). Ideally, I would like the buttons to show on single posts, but the SVG
   icons to be usable anywhere on the site. You get me now?
 * NB: Have you checked GeneratePress btw? I find its hooks easier to use than the
   Genesis Framework.
    -  This reply was modified 6 years, 4 months ago by [callaloo](https://wordpress.org/support/users/callaloo/).
 *  Plugin Author [Robin Cornett](https://wordpress.org/support/users/littlerchicken/)
 * (@littlerchicken)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/code-conflict-3/#post-12337230)
 * So you don’t actually need the buttons outside of the single posts; you just 
   want the icons? In that case, I would not use the can do buttons filter at all,
   because then you are getting yourself into a situation where the buttons will
   output even when you do not want them to. Instead, I would just load the icons
   into site independently, with something like this:
 *     ```
       add_action( 'wp_head', function() {
       	if ( function_exists( 'scriptlesssocialsharing_svg' ) ) {
       		scriptlesssocialsharing_svg();
       	}
       } );
       ```
   
 * After that, I suppose you should be able to use the icons anywhere the svg element
   is supported, but that’s really outside the scope of plugin support.
 *  Thread Starter [callaloo](https://wordpress.org/support/users/callaloo/)
 * (@callaloo)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/code-conflict-3/#post-12337367)
 * I just figured a workaround. Copied the brands.svg to a new folder then called
   the file path in my custom functions plugin. Then assigned some height and width
   CSS. Works perfectly. Thanks.

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

The topic ‘Code conflict’ is closed to new replies.

 * ![](https://ps.w.org/scriptless-social-sharing/assets/icon-256x256.jpg?rev=1361689)
 * [Scriptless Social Sharing](https://wordpress.org/plugins/scriptless-social-sharing/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/scriptless-social-sharing/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/scriptless-social-sharing/)
 * [Active Topics](https://wordpress.org/support/plugin/scriptless-social-sharing/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/scriptless-social-sharing/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/scriptless-social-sharing/reviews/)

 * 6 replies
 * 2 participants
 * Last reply from: [callaloo](https://wordpress.org/support/users/callaloo/)
 * Last activity: [6 years, 4 months ago](https://wordpress.org/support/topic/code-conflict-3/#post-12337367)
 * Status: resolved