Skip to content

Instantly share code, notes, and snippets.

Avatar

Brad Dalton braddalton

View GitHub Profile
@braddalton
braddalton / class-custom-feed.php
Created May 30, 2019 — forked from ocean90/class-custom-feed.php
How to add a custom feed to WordPress
View class-custom-feed.php
<?php
/**
* Add a custom feed to WordPress.
*
* The feed will be rendered through the wp-includes/feed-rss2.php template
* and avaiable under example.com/feed/{$feed_slug}.
*
* Note: Don't forget to flush the rewrite rules once.
*
* @author Dominik Schilling
View credits-1.php
<?php
//* Do NOT include the opening php tag shown above. Copy the code shown below.
//* Customize the credits
add_filter( 'genesis_footer_creds_text', 'sp_footer_creds_text' );
function sp_footer_creds_text() {
echo '<div class="creds"><p>';
echo 'Copyright &copy; ';
echo date('Y');
echo ' &middot; <a href="http://mydomain.com">My Custom Link</a> &middot; Built on the <a href="http://www.studiopress.com/themes/genesis" title="Genesis Framework">Genesis Framework</a>';
@braddalton
braddalton / functions.php
Last active Oct 11, 2017 — forked from pippinsplugins/gist:9641841
Track Users I.P Address in WordPress Theme
View functions.php
add_action( 'loop_start', 'display_users_ip_address' );
function display_users_ip_address() {
if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) {
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
@braddalton
braddalton / functions.php
Last active Apr 16, 2019 — forked from studiopress/nav-extras.php
Add Search Form To Nav Menu In Genesis
View functions.php
add_filter( 'wp_nav_menu_items', 'add_search_genesis_menu', 10, 2 );
function add_search_genesis_menu( $menu, $args ) {
if ( 'primary' !== $args->theme_location )
return $menu;
ob_start();
get_search_form();
$search = ob_get_clean();
$menu .= '<li class="search">' . $search . '</li>';
@braddalton
braddalton / page_blog.php
Last active Sep 5, 2017 — forked from studiopress/page_blog.php
Remove Featured Image From Genesis Blog Page https://wp.me/p1lTu0-gNB
View page_blog.php
<?php
//* Template Name: Custom Blog
genesis();
@braddalton
braddalton / gist:e1e1e69ceea697fb20fcc6fb3b4e216a
Created Dec 5, 2016 — forked from mikejolley/gist:2044101
WooCommerce - Show number of items in cart and total
View gist:e1e1e69ceea697fb20fcc6fb3b4e216a
<a class="cart-contents" href="<?php echo wc_get_cart_url(); ?>" title="<?php _e( 'View your shopping cart' ); ?>"><?php echo sprintf ( _n( '%d item', '%d items', WC()->cart->get_cart_contents_count() ), WC()->cart->get_cart_contents_count() ); ?> - <?php echo WC()->cart->get_cart_total(); ?></a>
View Example of jQuery Backstretch Slideshow
var position = 0,
images = [
'image1.jpg',
'image2.jpg',
'image3.jpg'
];
$.backstretch(images[position]);
setInterval(function() {
if(position++ > images.length) position = 0;
View functions.php
<?php
//* Start the engine
include_once( get_template_directory() . '/lib/init.php' );
//* Setup Theme
include_once( get_stylesheet_directory() . '/lib/theme-defaults.php' );
//* Set Localization (do not remove)
load_child_theme_textdomain( 'outreach', apply_filters( 'child_theme_textdomain', get_stylesheet_directory() . '/languages', 'outreach' ) );
@braddalton
braddalton / columns.css
Created Jun 20, 2016 — forked from studiopress/columns.css
Genesis column classes.
View columns.css
/* Column Classes
Link: http://twitter.github.io/bootstrap/assets/css/bootstrap-responsive.css
--------------------------------------------- */
.five-sixths,
.four-sixths,
.one-fourth,
.one-half,
.one-sixth,
.one-third,
View functions.php
function add_bulk_async_sdk() { ?>
<script>
(function(doc, script) {
var js,
fjs = doc.getElementsByTagName(script)[0],
add = function(url, id) {
if (doc.getElementById(id)) {return;}
js = doc.createElement(script);
js.src = url;
id &amp;&amp; (js.id = id);