Skip to content

Instantly share code, notes, and snippets.

View davekuhar's full-sized avatar
🧑‍🚀

Dave Kuhar davekuhar

🧑‍🚀
  • 23:21 (UTC -04:00)
View GitHub Profile
@davekuhar
davekuhar / topnav.php
Last active December 21, 2015 22:59
Function to add top nav section
<?php
// In functions.php:
add_action('genesis_before_header', 'child_include_topnav');
function child_include_topnav() {
require(CHILD_DIR.'/lib/topnav.php');
}
// In /lib/topnav.php
@davekuhar
davekuhar / olde-genesis-home.php
Created August 29, 2013 15:22
Ye olde way of doing Genesis home pages…
<?php get_header(); ?>
<?php genesis_before_content_sidebar_wrap(); ?>
<div id="content-sidebar-wrap">
<?php genesis_before_content(); ?>
<div id="content" class="hfeed">
<div id="home-top">
<?php if (!dynamic_sidebar('Home Top')) : ?>
@davekuhar
davekuhar / 0_reuse_code.js
Created May 28, 2014 00:09
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
<?php
add_action( 'wp_enqueue_scripts', 'child_load_google_fonts' );
/**
* Enqueue Google Fonts using a function
* via Rickaby http://gregrickaby.com/add-google-fonts-wordpress-right-way/
*/
function child_load_google_fonts() {
// Find out which http protocol our server is, so we can match google
@davekuhar
davekuhar / Delete subscribers from WordPress database
Created September 16, 2014 17:35
Delete subscribers from WordPress database
# First, delete all subscribers
DELETE wpu FROM wp_users AS wpu
INNER JOIN wp_usermeta AS wpm ON wpu.ID = wpm.user_id
WHERE wpm.meta_key = 'wp_capabilities' AND wpm.meta_value = 'a:1:{s:10:"subscriber";b:1;}';
UPDATE wp_posts SET post_author = 1;
# Then, delete the user meta
DELETE FROM wp_usermeta WHERE user_id NOT IN (SELECT ID FROM wp_users)
@davekuhar
davekuhar / favicon-package.php
Last active August 29, 2015 14:07
Add favicon package to Genesis theme
// add favicon package
function xmit_add_favicons() {?>
<!-- ADD FAVICON PACKAGE -->
<link rel="apple-touch-icon" sizes="57x57" href="<?php echo get_stylesheet_directory_uri() ?>/images/favicon-package/apple-touch-icon-57x57.png">
<link rel="apple-touch-icon" sizes="114x114" href="<?php echo get_stylesheet_directory_uri() ?>/images/favicon-package/apple-touch-icon-114x114.png">
<link rel="apple-touch-icon" sizes="72x72" href="<?php echo get_stylesheet_directory_uri() ?>/images/favicon-package/apple-touch-icon-72x72.png">
<link rel="apple-touch-icon" sizes="144x144" href="<?php echo get_stylesheet_directory_uri() ?>/images/favicon-package/apple-touch-icon-144x144.png">
<link rel="apple-touch-icon" sizes="60x60" href="<?php echo get_stylesheet_directory_uri() ?>/images/favicon-package/apple-touch-icon-60x60.png">
<link rel="apple-touch-icon" sizes="120x120" href="<?php echo get_stylesheet_directory_uri() ?>/images/favicon-package/apple-touch-icon-120x120.png">
<link rel="apple-touch-icon" sizes="76x76" href="<?
@davekuhar
davekuhar / favicon-url.php
Last active August 29, 2015 14:07
Path to paste into field at realfavicongenerator.net
<?php echo get_stylesheet_directory_uri() ?>/images/favicon-package
@davekuhar
davekuhar / replace-howdy.php
Last active December 20, 2016 01:28
Replace Howdy
// replace WordPress Howdy
function replace_howdy( $wp_admin_bar ) {
$my_account=$wp_admin_bar->get_node('my-account');
$newtitle = str_replace( 'Howdy,', 'Logged in as:', $my_account->title );
$wp_admin_bar->add_node( array(
'id' => 'my-account',
'title' => $newtitle,
) );
}
add_filter( 'admin_bar_menu', 'replace_howdy',25 );
@davekuhar
davekuhar / category-slug-as-body-class.php
Last active August 29, 2015 14:08
Add category slug as body class
<?php
// to the body element, add category slug as a class so we can style posts by category
add_filter('body_class','add_category_to_single');
function add_category_to_single($classes) {
if (is_single() ) {
global $post;
foreach((get_the_category($post->ID)) as $category) {
// add category slug to the $classes array
$classes[] = $category->category_nicename;
}