Skip to content

Instantly share code, notes, and snippets.

View jerewall's full-sized avatar

Jeremy Wallace jerewall

View GitHub Profile
@jerewall
jerewall / main.css
Created October 23, 2015 14:18
Only print the content area!
@media print {
body * {
visibility: hidden; }
.content * {
visibility: visible; }
.content {
position: absolute;
left: 0;
top: 0; } }
@jerewall
jerewall / various.php
Created June 16, 2015 18:09
Have a different sub nav for each page in wordpress dynamically
Have a different sub nav for each page.
1.) add the following to functions.php of your theme:
functions:
register_sidebar( array(
'name' => __( 'Secondary Nav', 'twentytwelve' ),
'id' => 'sidebar-4',
'description' => __( 'Appears when there is children from the main nav. Must manually enable.', 'twentytwelve' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
@jerewall
jerewall / js.js
Last active August 29, 2015 14:22
Equal Height Content and Sidebars using Jquery
<script>
// the tallest column on the page will be the example for all other elements with class .col making them all as tall as the tallest.
$(window).load(function() {
var tallest = 0;
$('.col').each(function(){
if($(this).outerHeight() > tallest) tallest = $(this).outerHeight();
});
@jerewall
jerewall / main.css
Created May 15, 2015 15:49
Full Width Centered Slider Images for Wordpress using Meta Slider
/*SLIDER */
.slider { width: 100%; height: 573px; overflow: hidden; position: relative; margin-bottom:11px; margin-top: -5px; }
.slider .metaslider .slides img { height:573px; position: absolute; left: 50%; -webkit-transform: translateX(-50%); -moz-transform: translateX(-50%); -ms-transform: translateX(-50%); -o-transform: translateX(-50%); transform: translateX(-50%); width: 2000px; }
@jerewall
jerewall / main.css
Created May 7, 2015 13:26
Make Meta Slider in wordpress full width and height and always centered
.slider { width: 100%; height: 272px; overflow: hidden; position: relative; margin-bottom:11px; background:#434575; border-top:5px solid #C53D3D; }
.slider .metaslider .slides img { height:267px; position: absolute; left: 50%; -webkit-transform: translateX(-50%); -moz-transform: translateX(-50%); -ms-transform: translateX(-50%); -o-transform: translateX(-50%); transform: translateX(-50%); width: 2000px; }
@jerewall
jerewall / functions.php
Last active August 29, 2015 14:20
limit the amount of the excerpt, and then display read more.
// =========================================================================================
/* limit the amount of the excerpt, and then display read more.
HTML:
<?php the_excerpt(32); ?>
PHP for functions:
*/
function excerpt($limit) {
@jerewall
jerewall / header.php
Last active August 29, 2015 14:19
Get Featured Image and use it in a banner on any page, therefore every page can have a different banner.
<div class="slider center cf">
<?php if(has_post_thumbnail()) {
the_post_thumbnail("full", array('class'=>"banner-image"));
} else { ?>
<img src="<?php echo get_template_directory_uri(); ?>/images/banner.jpg" class="banner-image" alt="Banner Image">
<?php } ?>
</div>
@jerewall
jerewall / printme.js
Created March 23, 2015 13:29
Printable Divs - Print only whats inside of the div of choice using JS
//in your html use the following:
<div id="printableArea">
<h1>Print me</h1>
</div>
<input type="button" onclick="printDiv('printableArea')" value="print a div!" />
//in your head/scripts area.. use the following:
<script type="text/javascript">
@jerewall
jerewall / header.js
Created March 18, 2015 15:28
Add this buttons share code
//in header.php
<script src="//s7.addthis.com/js/300/addthis_widget.js" type="text/javascript"></script>
// in html
<div class="addthis_toolbox addthis_default_style addthis_32x32_style">
<a class="addthis_button_facebook"></a>
<a class="addthis_button_twitter"></a>
<a class="addthis_button_email"></a>
<a class="addthis_button_print"></a>
<a class="addthis_button_compact"></a>
@jerewall
jerewall / functions.php
Created March 13, 2015 20:38
redirects old URLs to new location in wordpress via functions.php
/* redirects old URLs to new location*/
add_action('template_redirect','my_template_redirect');
function my_template_redirect() {
$redirect_to = false;
list($url_path,$params) = explode('?',$_SERVER['REQUEST_URI']);
$path_parts = explode('/',trim($url_path,'/'));
switch ($path_parts[0]) {
case 'previous-url.php':
$redirect_to = '/new-page-url/';