Skip to content

Instantly share code, notes, and snippets.

View jerewall's full-sized avatar

Jeremy Wallace jerewall

View GitHub Profile
@jerewall
jerewall / global.js
Created May 16, 2016 13:38
Short Page Fix
$('.container').css('min-height',$(window).height()-$('.footer').outerHeight(true)+'px');
@jerewall
jerewall / style.css
Created May 16, 2016 13:37
Fancy Blockquote
blockquote {
margin: 0.25em 0;
padding: 0.35em 94px;
position: relative;
color: #383838;
}
blockquote:before {
display: block;
padding-left: 10px;
@jerewall
jerewall / header.php
Created May 16, 2016 13:36
Wordpress Site Title
<?php echo get_bloginfo('name'); ?>
@jerewall
jerewall / header.php
Created May 16, 2016 13:35
Google Translate Code
<div class="google-translate">
<div id="google_translate_element"></div>
<script>function googleTranslateElementInit() { new google.translate.TranslateElement({pageLanguage: 'en', layout: google.translate.TranslateElement.InlineLayout.SIMPLE }, 'google_translate_element');}</script>
<script src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
</div>
@jerewall
jerewall / global.js
Last active May 16, 2016 13:27
​ Make any site have a floating navigation, even if Wordpress Admin Bar is present!
//Sticky navigation bar - Make the navigation area float after scrolling past it//
var aboveHeight = $('#primary-navigation').offset().top;
jQuery(window).scroll(function() {
if ($(window).scrollTop() > aboveHeight) {
$('nav').css({
position: 'fixed',
top: 0,
'z-index': 9999
});
$('.row-3').css({
@jerewall
jerewall / global.js
Last active May 16, 2016 13:25
​ Stick the #nav to the top of the window (see new version after this)
// Stick the #nav to the top of the window //
var nav = $('#primary-navigation');
var navHomeY = nav.offset().top;
var isFixed = false;
var $w = $(window);
$w.scroll(function () {
var scrollTop = $w.scrollTop();
var shouldBeFixed = scrollTop > navHomeY;
if (shouldBeFixed && !isFixed) {
nav.css({
@jerewall
jerewall / style.css
Created May 16, 2016 13:23
1shoppingcart - Make the store products display more than 3 in a row, responsive
#page div.results-grid {
border-collapse: separate;
display: table;
width: 100%;
}
#page div.results-grid .results-row {
display: block;
width: 100%;
}
#page div.results-grid .result {
@jerewall
jerewall / header.php
Created May 16, 2016 13:20
​ Have a slider on homepage, featured image on all pages but home, and use the blog featured image on the blog page.
<?php
if (is_home() && get_option('page_for_posts') ) {
$featured_image = wp_get_attachment_image_src(get_post_thumbnail_id(get_option('page_for_posts')),'full');
} else {
$featured_image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'featured-image', false);
}
if(is_front_page()) {
echo do_shortcode("[metaslider id=1081]");
} elseif($featured_image) {
echo '<img src="'.$featured_image[0].'" width="'.$featured_image[1].'" height="'.$featured_image[2].'" alt="'.esc_attr( get_bloginfo(
@jerewall
jerewall / file.php
Created May 16, 2016 13:19
Using GLOB to retrieve file list from directory and display it and link to itself
<?php $thumbs = glob("docs/*.{pdf,doc,docx}", GLOB_BRACE); ?>
<?php
if(count($thumbs)) {
natcasesort($thumbs);
foreach($thumbs as $thumb) {
?>
<p><a href="<?php echo $thumb ?>" target="_blank"><?php echo str_replace(array('docs/','.pdf','.doc','.docx'), '', $thumb); ?></a> </p>
<?php
}} else {
echo "Sorry, no documents to display!";
@jerewall
jerewall / functions.php
Created May 16, 2016 13:18
short code maker
//short code maker:
// reviews widget provided by customer
function shortcodenamehere_function() {
$text = <<<TEXT
(Insert any code here)
TEXT;
return $text;
}
add_shortcode('shortcodenamehere', 'shortcodenamehere_function');