Skip to content

Instantly share code, notes, and snippets.

View JiveDig's full-sized avatar

Mike Hemberger JiveDig

View GitHub Profile
@norcross
norcross / calc-read-time.php
Created July 3, 2014 02:51
calculate and display an estimated reading time
<?php
/**
* handle the calculation
* @param integer $seconds [description]
* @return [type] [description]
*/
function rkv_calc_read_time( $seconds = 0 ) {
// calc the minutes
@vladimirtsyupko
vladimirtsyupko / gist:10964772
Created April 17, 2014 08:32
Git force pull to overwrite local files
git fetch --all
git reset --hard origin/master
git pull origin master
@xeoncross
xeoncross / domdocument_encoding.php
Last active December 18, 2024 19:46
Fix HTML encoding errors with PHP DOMDocument
<?php
// Ignore errors
libxml_use_internal_errors(true) AND libxml_clear_errors();
// http://stackoverflow.com/q/10237238/99923
// http://stackoverflow.com/q/12034235/99923
// http://stackoverflow.com/q/8218230/99923
// original input (unknown encoding)
@JiveDig
JiveDig / featured_image_on_single_post.php
Created December 4, 2013 21:45
Show featured image (post thumbnail) on single posts
<?php
// Show featured image on single posts
add_action( 'genesis_before_entry_content', 'child_featured_post_image', 8 );
function child_featured_post_image() {
if ( ! is_singular( 'post' ) ) return;
the_post_thumbnail('post-image');
}
@JiveDig
JiveDig / display_widget_area.php
Last active December 27, 2015 19:19
Display a genesis widget area
<?php
if ( is_active_sidebar( 'after-entry' ) ) {
genesis_widget_area( 'after-entry', array(
'before' => '<div class="after-entry">',
'after' => '</div>',
) );
}
@JiveDig
JiveDig / register_new_widget_area.php
Created November 8, 2013 19:55
Register new Genesis widget area
//* Register widget areas
genesis_register_sidebar( array(
'id' => 'after-post',
'name' => __( 'After Post', 'theme-name' ),
'description' => __( 'This is the widget that appears after a single posts.', 'theme-name' ),
) );
@JiveDig
JiveDig / link_featured_image_to_post.php
Created November 8, 2013 15:26
Link featured image (post thumbnail) to the post. Use the_title_attribute()
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail('book-thumbnail', array('class' => 'book-thumbnail')); ?></a>
@JiveDig
JiveDig / change_breadcrumbs.php
Created November 7, 2013 20:02
Change the Genesis breadcrumbs
// Change breadcrumb text/args
add_filter( 'genesis_breadcrumb_args', 'child_breadcrumb_args' );
function child_breadcrumb_args( $args ) {
$args['home'] = 'Home';
$args['sep'] = ' / ';
$args['list_sep'] = ', '; // Genesis 1.5 and later
$args['prefix'] = '<div class="breadcrumb">';
$args['suffix'] = '</div>';
$args['heirarchial_attachments'] = true; // Genesis 1.5 and later
$args['heirarchial_categories'] = true; // Genesis 1.5 and later
// 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' );
get_option( 'woocommerce_terms_page_id' );
@JiveDig
JiveDig / remove_post_content.php
Created October 29, 2013 02:34
Remove post content
//* Remove the post content (requires HTML5 theme support)
remove_action( 'genesis_entry_content', 'genesis_do_post_content' );