Skip to content

Instantly share code, notes, and snippets.

@arelthia
arelthia / catreadmore.php
Created July 21, 2014 21:43
Different Read More For Specific Category
//custom readmore for a specific category
add_filter( 'excerpt_more', 'pp_cat_more_link' );
function pp_cat_more_link() {
if(is_category('podcasts' )){
return ' <a class="more-link" href="' . get_permalink() . '">Listen Now</a>';
}else{
return ' <a class="more-link" href=' . get_permalink() . '">Read More...</a>';
}
}
@arelthia
arelthia / two-shipping-in-cart.php
Last active October 26, 2016 22:54
Woocommerce: Different shipping methods for different products in single cart
/** Seperate freepromo products from other Items - forcing multiple carts **/
add_filter( 'woocommerce_cart_shipping_packages', 'ps_two_shipping_methods_in_cart' );
function ps_two_shipping_methods_in_cart( $packages ) {
$packages = array();
$freepromo_items = array();
$regular_items = array();
$freeshipclass= 'freepromo';
$shipto = array(
'country' => WC()->customer->get_shipping_country(),
@arelthia
arelthia / tips.php
Created January 8, 2015 01:42
Tips Meta Box
<?php //You will probally need to remove this
function tip_meta_box(){
add_meta_box('tip_box', 'Things to Remember', 'tip_callback', 'post', 'side', 'high');
}
add_action('add_meta_boxes', 'tip_meta_box');
function tip_callback($post){
?>
@arelthia
arelthia / old to be replaced
Last active August 29, 2015 14:23
Only show terms of service for specific product.
//Conditional Terms of Service
add_filter( 'woocommerce_checkout_show_terms' , 'syb_remove_terms' );
function syb_remove_terms( $fields ) {
foreach ( WC()->cart->get_cart() as $item ) {
if ( $item['product_id'] == '401') {
return true;
}
@arelthia
arelthia / gist:47ae6a545a6b0d8c9bec
Last active August 29, 2015 14:23
Return to Shop and continue shopping Redirect
add_filter( 'woocommerce_return_to_shop_redirect', 'syb_shop_redirect' );
function syb_shop_redirect(){
return 'https://simontbailey.com/shiftyourbrilliance/';
}
@arelthia
arelthia / mobile_script.js
Last active August 29, 2015 14:23
Change the mobile menu into a mobile friendly menu.
jQuery(document).ready(function() {
jQuery(".builder-module-navigation .menu").addClass("mobile-menu-hidden");
jQuery(".builder-module-navigation").addClass("mobile");
jQuery(".mobile-menu-hidden").before('<div class="mobile-menu">&#8801; Menu</div>');
jQuery(".mobile-menu").click(function(){
jQuery(this).next().slideToggle();
});
@arelthia
arelthia / awac-grid.css
Created July 2, 2015 15:37
Placing Widget in AWAC Sidebar Side by Side
.awac-wrapper{
width: 50%;
display: inline-block;
}
@arelthia
arelthia / gist:49f760f06549c2baaa5b
Last active August 29, 2015 14:24
Change the WooCommerce Product Description Heading
//Change the Product description heading
add_filter('woocommerce_product_description_heading', 'ps_custom_product_description_heading');
function ps_custom_product_description_heading(){
return __( 'Custom Product Description' );
}
@arelthia
arelthia / single-{cptname}.php
Created July 14, 2015 00:13
Remove entry footer
<?php
/*
Template Name: Single {CPT}
*/
remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_open', 5 );
remove_action( 'genesis_entry_footer', 'genesis_post_meta' );
remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_close', 15 );
genesis();
@arelthia
arelthia / functions.php
Created August 6, 2015 17:03
Set front page when Pod CPT is saved.
add_action('pods_api_post_save_pod_item_book', 'tht_set_home', 10, 3);
function tht_set_home( $pieces, $is_new_item, $id ) {
//get the value of the 'genre' field
$featured =$pieces[ 'fields' ][ 'book_featured' ][ 'value' ];
$blog = get_page_by_path( 'blog' );
if( $featured ){
update_option( 'show_on_front', 'page' );