Skip to content

Instantly share code, notes, and snippets.

View jlittlejohn's full-sized avatar

Josh Littlejohn jlittlejohn

View GitHub Profile
@jlittlejohn
jlittlejohn / WP searchform.php
Last active May 1, 2019 16:10
WP: searchform.php
<form method="get" role="search" id="searchform" class="navbar-search" action="<?php echo home_url( '/' ); ?>">
<input type="text" name="s" id="s" value="<?php the_search_query(); ?>" class="search-query" placeholder="Search">
<input type="hidden" id="searchsubmit">
</form>
@jlittlejohn
jlittlejohn / CSS Image Replacement
Last active May 1, 2019 16:10
CSS: Image Replacement
.ir {
border: 0;
font: 0/0 a;
text-shadow: none;
color: transparent;
background: transparent;
}
@jlittlejohn
jlittlejohn / KML locations.kml
Last active May 1, 2019 16:09
KML: locations.kml
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">
<Document>
<name>Locations for {{businessName}}.</name>
<atom:link rel="related" href="{{businessURL}}" />
<Folder>
<Placemark>
<name><![CDATA[{{businessName}}]]></name>
<address><![CDATA[{{businessAddress}}]]></address>
<description><![CDATA[{{businessDescription}}]]></description>
@jlittlejohn
jlittlejohn / XML geositemap.xml
Last active May 1, 2019 16:09
XML: geositemap.xml
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:geo="http://www.google.com/geo/schemas/sitemap/1.0">
<url>
<loc>http://www.{{URL}}.com/locations.kml</loc>
<geo:geo>
<geo:format>kml</geo:format>
</geo:geo>
</url>
</urlset>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div <?php post_class(); ?> id="post-<?php the_ID(); ?>">
<h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
<?php the_content(); ?>
</div>
<?php endwhile; ?>
<div class="navigation">
@jlittlejohn
jlittlejohn / WP: Loop with WP_Query()
Created September 11, 2012 23:15
WP: Loop with WP_Query()
<?php $custom_query = new WP_Query('cat=-9'); // exclude category 9
while($custom_query->have_posts()) : $custom_query->the_post(); ?>
<div <?php post_class(); ?> id="post-<?php the_ID(); ?>">
<h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
<?php the_content(); ?>
</div>
<?php endwhile; ?>
<?php wp_reset_postdata(); // reset the query ?>
@jlittlejohn
jlittlejohn / WP: Loop with get_posts()
Created September 11, 2012 23:15
WP: Loop with get_posts()
<!-- Used to get an array of posts -->
<?php global $post; // required
$args = array(
'posts_per_page' => 5,
'numberposts' => 5,
'offset' => 0,
'category' => '',
'orderby' => 'post_date',
'order' => 'DESC',
'include' => '',
@jlittlejohn
jlittlejohn / WP Touch Icons
Created September 11, 2012 23:20
WP: Touch Icons
<link rel="apple-touch-icon" sizes="144x144" href="<?php echo get_template_directory_uri() ?>/img/ico/apple-touch-icon-144x144.png">
<link rel="apple-touch-icon" sizes="114x114" href="<?php echo get_template_directory_uri() ?>/img/ico/apple-touch-icon-114x114.png">
<link rel="apple-touch-icon" sizes="72x72" href="<?php echo get_template_directory_uri() ?>/img/ico/apple-touch-icon-72x72.png">
<link rel="apple-touch-icon" href="<?php echo get_template_directory_uri() ?>/img/ico/apple-touch-icon.png">
<link rel="shortcut icon" href="<?php echo get_template_directory_uri() ?>/img/ico/favicon.ico">
@jlittlejohn
jlittlejohn / WP: Logo
Created September 11, 2012 23:23
WP: Logo
@jlittlejohn
jlittlejohn / JS Hide Address Bar for iOS Android
Last active May 1, 2019 15:54
JS: Hide Address Bar for iOS & Android
/*
* Normalized hide address bar for iOS & Android
* (c) Scott Jehl, scottjehl.com
* MIT License
*/
(function( win ){
var doc = win.document;
// If there's a hash, or addEventListener is undefined, stop here
if( !location.hash && win.addEventListener ){