Skip to content

Instantly share code, notes, and snippets.

Avatar

Brad Dalton braddalton

View GitHub Profile
@braddalton
braddalton / Filter Genesis Post Titles
Last active Aug 26, 2019
Filter Genesis Entry Title Wrap Heading Tags https://wp.me/p1lTu0-grX
View Filter Genesis Post Titles
/**
* Filter Genesis H1 Post Titles to add <span> for styling
*
*/
add_filter( 'genesis_post_title_output', 'filter_genesis_post_title_tags', 15 );
function filter_genesis_post_title_tags( $title ) {
if ( is_singular() )
$title = sprintf( '<h1 class="entry-title"><span>%s</span></h1>', apply_filters( 'genesis_post_title_text', get_the_title() ) );
@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
@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>';
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>';
View Add Social Links & Icons To Genesis Nav Menu
View Customize or remove the post info function genesis
// Customize the post info function
add_filter( 'genesis_post_info', 'post_info_filter' );
function post_info_filter($post_info) {
$post_info = '[post_date] by [post_author_posts_link] [post_comments] [post_edit]';
return $post_info;
}
// Remove the post info function
remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );
@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 / 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;