• Resolved ZeroGravity

    (@zerogravity)


    If you are using a Genesis theme the plugin uses the genesis_entry_header and genesis_entry_footer actions. I gather these are not fired when the page is a WooCommerce product so the sharing icons are not displayed.

    I’m sure there is probably a better way to do this but I added the following code to the theme_location() funstion at line #54 in class-shared-counts-front.php.

    // WooCommerce Hooks.
    if ( is_woocommerce() ) {
    
    	$locations = [
    		'before' => [
    			'hook'     => 'woocommerce_before_single_product',
    			'filter'   => false,
    			'priority' => 13,
    			'style'    => false,
    		],
    		'after'  => [
    			'hook'     => 'woocommerce_after_single_product',
    			'filter'   => false,
    			'priority' => 8,
    			'style'    => false,
    		],
    	];
    
    // Genesis Hooks.
    } elseif ( 'genesis' === get_template() ) {
    • This topic was modified 3 years, 6 months ago by ZeroGravity. Reason: formatting
Viewing 1 replies (of 1 total)
  • Thread Starter ZeroGravity

    (@zerogravity)

    I should have kept reading. The plugin provides a filter so you can change the action hook that is used to display the icons. I added this to my core functionality plugin.

    /**
     * Move Shared Counts
     * @see https://sharedcountsplugin.com/2019/03/27/change-the-theme-location-for-share-buttons/
     *
     * @param array $locations
     * @return array
     */
    function be_shared_counts_location( $locations ) {
    	if ( is_woocommerce() ) {
    		// Before WC Product
    		$locations['before']['hook'] = 'woocommerce_before_single_product';
    		$locations['before']['filter'] = false;
    	
    		// After WC Product
    		$locations['after']['hook'] = 'woocommerce_after_single_product';
    		$locations['after']['filter'] = false;
    	}
    
    	return $locations;
    }
    add_filter( 'shared_counts_theme_locations', 'be_shared_counts_location' );
Viewing 1 replies (of 1 total)
  • The topic ‘Doesn’t display on WooCommerce products if using a Genesis theme’ is closed to new replies.