Skip to content

Instantly share code, notes, and snippets.

View Deaner666's full-sized avatar

Dave Dean Deaner666

View GitHub Profile
@Deaner666
Deaner666 / page.php
Created May 26, 2015 21:34
Outputting a URL parameter in PHP
<?php
if ( isset($_GET['key']) ) {
echo $_GET['key'];
} else {
// Fallback behaviour here
}
@Deaner666
Deaner666 / linking-page.php
Created May 26, 2015 21:20
Anchor syntax for linking to a page with URL parameters
<a href="http://www.example.com/page.php?key1=value&key2=value">link</a>
@Deaner666
Deaner666 / responsive-menu.js
Last active August 29, 2015 14:20
Selector override for Genesis responsive menus to make them aria accessible
$("#menu-primary-navigation").before('<button class="responsive-menu-icon" aria-controls="menu-primary-navigation" aria-expanded="false"><span class="screen-reader-text">Menu</span></button>');
@Deaner666
Deaner666 / functions.php
Last active August 29, 2015 14:13
Add 'read more' links to automatic excerpts, manual excerpts and teasers
<?php
// Add "Read More" link to automatic excerpts
add_filter('the_content_more_link', 'wpm_get_read_more_link');
add_filter('get_the_content_more_link', 'wpm_get_read_more_link'); // Genesis Framework only
add_filter('excerpt_more', 'wpm_get_read_more_link');
function wpm_get_read_more_link() {
global $post;
return '&hellip;&nbsp;<a href="' . get_permalink($post->ID) . '">[Continue&nbsp;reading] <span class="screen-reader-text">' . get_the_title() . '</span></a>';
}
@Deaner666
Deaner666 / functions.php
Last active August 29, 2015 14:13
Add a custom 'read more' link to automatic excerpts and teasers
<?php
// Add "Read More" link to automatic excerpts
add_filter('the_content_more_link', 'wpm_get_read_more_link');
add_filter('get_the_content_more_link', 'wpm_get_read_more_link'); // Genesis Framework only
add_filter('excerpt_more', 'wpm_get_read_more_link');
function wpm_get_read_more_link() {
global $post;
return '&hellip;&nbsp;<a href="' . get_permalink($post->ID) . '">[Continue&nbsp;reading] <span class="screen-reader-text">' . get_the_title() . '</span></a>';
}
@Deaner666
Deaner666 / functions.php
Created January 13, 2015 14:08
Add Genesis author box then remove it from everything except actual Posts
<?php
// Add author box to single posts and author archives
add_filter( 'get_the_author_genesis_author_box_single', '__return_true' );
add_filter( 'get_the_author_genesis_author_box_archive', '__return_true' );
// And remove it from anything that's not a post
add_action ('genesis_entry_footer', 'wpm_remove_author_box' );
function wpm_remove_author_box() {
if ( get_post_type() != 'post' ) {
@Deaner666
Deaner666 / functions.php
Last active August 29, 2015 14:13
Add author box to all post types (except pages) and then remove it from "Snippets" Custom Post Type
<?php
// Add author box to single posts and author archives
add_filter( 'get_the_author_genesis_author_box_single', '__return_true' );
add_filter( 'get_the_author_genesis_author_box_archive', '__return_true' );
// And remove it from anything that's not a post
add_action ('genesis_entry_footer', 'wpm_remove_author_box' );
function wpm_remove_author_box() {
if ( get_post_type() == 'snippet' ) {
@Deaner666
Deaner666 / functions.php
Last active August 29, 2015 14:13
Remove author box from everything except Posts
<?php
// And remove it from anything that's not a post
add_action ('genesis_entry_footer', 'wpm_remove_author_box' );
function wpm_remove_author_box() {
if ( get_post_type() != 'post' ) {
remove_action( 'genesis_after_entry', 'genesis_do_author_box_single', 8 );
}
}
@Deaner666
Deaner666 / functions.php
Created January 13, 2015 13:17
Add author box to all post types (except pages)
<?php
// Add author box to single posts and author archives
add_filter( 'get_the_author_genesis_author_box_single', '__return_true' );
add_filter( 'get_the_author_genesis_author_box_archive', '__return_true' );
@Deaner666
Deaner666 / functions.php
Last active August 29, 2015 14:07
Display custom meta on WooCommerce product_cat archive page
<?php
// Display details on product category archive pages
add_action( 'woocommerce_after_shop_loop', 'wpm_product_cat_archive_add_meta' );
function wpm_product_cat_archive_add_meta() {
$t_id = get_queried_object()->term_id;
$term_meta = get_option( "taxonomy_$t_id" );
$term_meta_content = $term_meta['custom_term_meta'];
if ( $term_meta_content != '' ) {