Skip to content

Instantly share code, notes, and snippets.

@arelthia
arelthia / variable.php
Created December 2, 2015 01:50
WooCommerce Change Attribute None Option
<?php
/**
* Variable product add to cart
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.4.0
* In theme/child theme directory add woocommerce/single-product/add-to-cart/
*/
if ( ! defined( 'ABSPATH' ) ) {
@arelthia
arelthia / front-page.php
Last active November 23, 2019 20:57
Pods find (query) based on field value - Used on Genesis home page
remove_action( 'genesis_loop', 'genesis_do_loop' );
add_action( 'genesis_loop', 'tht_featured_home', 5 );
function tht_featured_home() {
$where = "book_featured.meta_value='1'";
$params = array(
'where'=> $where,
'order' => 'ASC',
'limit' => 1,
@arelthia
arelthia / archive-book.php
Created August 6, 2015 17:48
Genesis Custom Pods Archive template
remove_action( 'genesis_loop', 'genesis_do_loop' );
add_action( 'genesis_loop', 'tht_book_archive_custom_loop' );
/**
* Genesis custom loop
*/
function tht_book_archive_custom_loop() {
$books = new Pod('book');
$params = array(
'order' => 'ASC',
'orderby' => 'title',
@arelthia
arelthia / functions.php
Created August 6, 2015 17:44
Change the label for Pods Groups. Create seperate groups(meta boxes).
function tht_add_pods_groups () {
pods_group_add( 'book', 'About The Book', 'book_featured, book_short_title, book_subtitle, book_cover_image, book_cover_caption, book_description, book_background_image, book_author, book_available_at' );
pods_group_add( 'place', 'Available From', 'place_name, place_link, place_icon, related_book' );
}
add_action( 'pods_meta_groups', 'tht_add_pods_groups' );
@arelthia
arelthia / functions.php
Last active August 29, 2015 14:26
Force CPT to use a specific template
/**
* Force Template
*/
add_filter( 'template_include', 'tht_force_template' );
function tht_force_template($template){
if ( 'cpt_name' == get_post_type()){
$template = get_query_template( 'template-name' );
}
return $template;
@arelthia
arelthia / functions.php
Created August 6, 2015 17:06
Change the number of post that are displayed per page for specific CPTs
add_action( 'pre_get_posts', 'tht_change_cpt_posts_per_page' );
/**
* Change Posts Per Page for CPT Archive
*/
function tht_change_cpt_posts_per_page( $query ) {
if( $query->is_main_query() && !is_admin() && (is_post_type_archive( 'definitions' )|| is_post_type_archive( 'question' )) ) {
$query->set( 'posts_per_page', '18' );
}
}
@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' );
@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 / 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 / awac-grid.css
Created July 2, 2015 15:37
Placing Widget in AWAC Sidebar Side by Side
.awac-wrapper{
width: 50%;
display: inline-block;
}