Skip to content

Instantly share code, notes, and snippets.

View wp-kitten's full-sized avatar

Costin wp-kitten

View GitHub Profile
<?php
// Get The Page ID You Need
get_option( 'woocommerce_shop_page_id' );
get_option( 'woocommerce_cart_page_id' );
get_option( 'woocommerce_checkout_page_id' );
get_option( 'woocommerce_pay_page_id' );
get_option( 'woocommerce_thanks_page_id' );
get_option( 'woocommerce_myaccount_page_id' );
get_option( 'woocommerce_edit_address_page_id' );
get_option( 'woocommerce_view_order_page_id' );
@wp-kitten
wp-kitten / gist:b2a17ecee789bc2a8fd1
Created February 16, 2015 13:58
Enable error logging WordPress
//============================================================================
// Enable WP_DEBUG mode
define('WP_DEBUG', true);
// Enable Debug logging to the /wp-content/debug.log file
define('WP_DEBUG_LOG', true);
// Disable display of errors and warnings
define('WP_DEBUG_DISPLAY', false);
@ini_set('display_errors',0);
@wp-kitten
wp-kitten / gist:07d71c9eac6b6dd34bd1
Created February 16, 2015 14:00
Change number of related products show on Single Product Page (WooCommerce)
// Redefine woocommerce_output_related_products()
function woocommerce_output_related_products() {
woocommerce_related_products(4,3); // Display 4 products in rows of 2
}
@wp-kitten
wp-kitten / gist:3d9e4ab293db63c20f7e
Last active August 29, 2015 14:15
Hide Shop button (WooCommerce)
public function __action_hideShopButton(){
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', '__action_hideShopButton');
@wp-kitten
wp-kitten / gist:bd190ea2bcf703cdf0ad
Created February 25, 2015 09:56
Admin bar menu entry to confirm the website is running on localhost
<?php
/*
* Add a new entry in the admin bar that will display the "LOCL INSTANCE" text.
* I find this approach especially useful when running remote websites on the
* localhost server and, because the URL is the same, it's hard to tell which
* is which. This new menu entry will confirm this is a local instance.
*
* Usage: Add this code to your theme's functions.php file
*
* Note: Do not forget to remove it when you upload changes to the remote server
@wp-kitten
wp-kitten / gist:f4d87fe697fabce93e37
Last active August 29, 2015 14:17
WooCommerce: Display upsells instead of related products
<?php
// @file: content-single-product.php
/*
* Display upsells if any
* - removes duplicated product information
*/
global $product;
$upsells = $product->get_upsells();
@wp-kitten
wp-kitten / gist:f16b1b74e434060fdbcc
Last active August 29, 2015 14:17
Bootstrap menu in WordPress
<?php
/*
Update button's data-target="#wpk-top-menu" attribute to match the wp_nav_menu's container_id key
*/
?>
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
data-target="#wpk-top-menu" aria-expanded="false" aria-controls="navbar">
@wp-kitten
wp-kitten / gist:79233437569b637ece19
Created March 20, 2015 12:06
Prevents a WodPress Core Theme from being activated.
<?php
/*
* Prevents a WodPress Core Theme from being activated.
*
* As a Theme Framework, it provides all the help and functionality child themes need, but child themes
* should be activated instead.
*
* This should go into the Core Theme's functions.php file
*/
if(! class_exists('CORE-THEME-MAIN-CLASS-NAME')) {
@wp-kitten
wp-kitten / gist:2bf444f0cc10bd06bf4e
Created March 31, 2015 09:23
WordPress Theme Activation/Deactivation hooks
<?php
/*
* Add this code to your theme's functions.php file
*/
// Theme activation
add_action("after_switch_theme", "theme_activated");
function theme_activation_hook(){
error_log('theme activated');
}
@wp-kitten
wp-kitten / gist:2059737515145d947009
Created April 6, 2015 03:35
WordPress WP_QUERY args
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query
* Source: http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/query.php
*/
$args = array(