Skip to content

Instantly share code, notes, and snippets.

View floroxmar's full-sized avatar

Joe Mar Aparecio floroxmar

View GitHub Profile
@floroxmar
floroxmar / functions.php
Created December 8, 2015 08:13
Allow site description or site tagline to render HTML tags
/**
* Allows site tagline/description to render HTML tags
*/
add_filter( 'genesis_seo_description', 'ja_allow_HTML_to_site_tagline', 10 ,3 );
function ja_allow_HTML_to_site_tagline( $description, $inside, $wrap ){
$inside = html_entity_decode( get_bloginfo( 'description' ) );
//* Build the description
$description = genesis_html5() ? sprintf( "<{$wrap} %s>", genesis_attr( 'site-description' ) ) : sprintf( '<%s id="description">%s</%s>', $wrap, $inside, $wrap );
@floroxmar
floroxmar / functions.php
Last active October 22, 2015 12:19
Add a default group other than "Registered" to all customers
/* Set group for all customers who purchased in the shop
* The customer will automatically assign to a group once the order is complete
* This code requires "Woocommerce", "Groups" and "Groups Woocommerce" plugin
*/
add_action( 'woocommerce_order_status_completed', 'ja_order_status_completed', 100 );
function ja_order_status_completed( $order_id ) {
if ( $order = Groups_WS_Helper::get_order( $order_id ) ) {
if ( $items = $order->get_items() ) {
if ( $user_id = $order->user_id ) {
@floroxmar
floroxmar / functions.php
Last active October 13, 2015 03:24
Set Featured Image on Archive/Blog Page and Video on single post
// Transfer featured image/video above the post title
// Show featured image on archive/blog page and video on single post page
remove_action( 'genesis_entry_content', 'genesis_do_post_image', 8 );
add_action( 'genesis_before_entry', 'ja_do_post_image_or_video', 8 );
function ja_do_post_image_or_video() {
global $post;
// Get the new custom field value
$video_iframe = get_post_meta( $post->ID, 'single_post_video', true );
@floroxmar
floroxmar / functions.php
Created April 27, 2015 14:18
Add Post Views on Post Info and Post Meta
// Add Post Views on Post Info
add_filter( 'genesis_post_info', 'ja_add_post_view_to_info' );
function ja_add_post_view_to_info($post_info) {
if ( !is_page() ) {
$post_info = '[post_date] by [post_author_posts_link] [post_comments] [postview] [post_edit]';
return $post_info;
}
}
// Add Post Views on Post Meta
@floroxmar
floroxmar / functions.php
Last active August 29, 2015 14:20
Add Post Views on Genesis Framework
// Add Post Views on Genesis Framework
/**
* Set Post Views
* It counts everytime single posts is viewed
*/
if ( !function_exists( 'ja_setPostViews' ) ){
function ja_setPostViews( $postID ){
$count_key = 'ja_post_views';
$count = get_post_meta($postID, $count_key, true);
@floroxmar
floroxmar / style.css
Created February 5, 2015 17:09
Custom archive template CSS
/*
* Custom Archive Page CSS
*/
.ja_archive_page{
display: block;
margin-bottom: 30px;
overflow: hidden;
}
.ja_archive_page ul{
@floroxmar
floroxmar / page_archive.php
Created February 5, 2015 16:58
Display Posts by Month in Genesis Archive Template
<?php
/**
* Template Name: Archive
*/
/** Force full width layout */
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' );
//* Remove standard post content output
remove_action( 'genesis_loop', 'genesis_do_loop' );
@floroxmar
floroxmar / functions.php
Created January 16, 2015 13:25
Display Product Category Custom Meta Field
<?php
/**
* Display Product Category Custom Meta Field
*/
$product_categories = get_terms( 'product_cat' );
foreach ( $product_categories as $category ) {
echo $category->meta['product_category_size'];
}
?>
@floroxmar
floroxmar / functions.php
Last active January 10, 2017 09:38
Add Custom Meta Fields in Product Category
<?php
/**
* Add Custom Meta Fields in Product Category
*/
if (class_exists( 'Woocommerce' )) {
function ja_taxonomy_custom_meta_field(){
add_action( 'product_cat_edit_form', 'ja_product_cat_field', 9 );
}
add_action( 'admin_init', 'ja_taxonomy_custom_meta_field' );
@floroxmar
floroxmar / functions.php
Last active August 29, 2015 14:05
Limit Excerpt by Character
add_filter( 'get_the_excerpt', 'ja_custom_excerpt' );
add_filter( 'the_excerpt', 'ja_custom_excerpt' );
function ja_custom_excerpt( $excerpt ){
$custom_excerpt = substr( $excerpt , 0, 20);
return $custom_excerpt;
}