Last active
August 7, 2017 09:03
-
-
Save BFTrick/4996955 to your computer and use it in GitHub Desktop.
A WordPress plugin that modifies the WooCommerce category page. It remove the title, price, and add to cart button. Reference this WordPress Answers question (http://wordpress.stackexchange.com/questions/61398/hide-price-title-in-store-thumbnail-dispay) to see why I made it.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: My WooCommerce Modifications | |
Plugin URI: http://woothemes.com/ | |
Description: Modificatinos to my WooCommerce site | |
Version: 1.0 | |
Author: Patrick Rauland | |
Author URI: http://www.patrickrauland.com/ | |
License: GPL version 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html | |
*/ | |
/* Copyright 2013 Patrick Rauland | |
This program is free software; you can redistribute it and/or modify | |
it under the terms of the GNU General Public License, version 2, as | |
published by the Free Software Foundation. | |
This program is distributed in the hope that it will be useful, | |
but WITHOUT ANY WARRANTY; without even the implied warranty of | |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
GNU General Public License for more details. | |
You should have received a copy of the GNU General Public License | |
along with this program; if not, write to the Free Software | |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
*/ | |
/** | |
* Check if WooCommerce is active | |
**/ | |
if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) { | |
// remove default woocommerce actions | |
function my_woocommerce_modifications() | |
{ | |
// hide product price on category page | |
remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10); | |
// hide add to cart button on category page | |
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10); | |
} | |
add_action( 'init', 'my_woocommerce_modifications' ); | |
// remove the title on the category shop page | |
function my_woocommerce_title_modifications($title, $id) | |
{ | |
// if we're on the category shop page then return nothing. | |
if(in_the_loop() && is_product_category()) | |
{ | |
return ""; | |
} | |
return $title; | |
} | |
add_filter( 'the_title', 'my_woocommerce_title_modifications'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this, man. Nice.