Skip to content

Instantly share code, notes, and snippets.

View jerewall's full-sized avatar

Jeremy Wallace jerewall

View GitHub Profile
@jerewall
jerewall / header.php
Last active August 29, 2015 14:15
Wordpress Header Image
// Wordpress Header Image - Allows you to use the wordpress header GUI to add banners in your theme.
<?php if ( get_header_image() ) : ?>
<a href="<?php echo esc_url( home_url( '/' ) ); ?>"><img src="<?php header_image(); ?>" class="header-image" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="" /></a>
<?php endif; ?>
$('img.swap').click(function() {
var src = ($(this).attr('src'));
var swap = ($(this).data('swap'));
$(this).attr('src', swap );
$(this).data('swap', src );
});
// <img src="images/pic1.jpg" data-swap="images/pic2.jpg" class="swap">
@jerewall
jerewall / gist:e31c87b254b158fb88a3
Created February 13, 2015 16:21
Emmet Make a Gallery using Tab
a[href="gallery/gallery$.jpg" rel="gallery"]*10>img[src="gallery/gallery$.jpg" alt="Gallery Image"]
Sample Ouput:
<a href="gallery/gallery1.jpg" rel="shadowbox"><img src="gallery/gallery1.jpg" alt="Gallery Image"></a>
<a href="gallery/gallery2.jpg" rel="shadowbox"><img src="gallery/gallery2.jpg" alt="Gallery Image"></a>
<a href="gallery/gallery3.jpg" rel="shadowbox"><img src="gallery/gallery3.jpg" alt="Gallery Image"></a>
<a href="gallery/gallery4.jpg" rel="shadowbox"><img src="gallery/gallery4.jpg" alt="Gallery Image"></a>
<a href="gallery/gallery5.jpg" rel="shadowbox"><img src="gallery/gallery5.jpg" alt="Gallery Image"></a>
<?php $my_query = new WP_Query( 'posts_per_page=3' );
while ( $my_query->have_posts() ) : $my_query->the_post();
$do_not_duplicate = $post->ID; ?>
<div class="entry">
<h3><?php the_title(); ?></h3>
<?php the_excerpt(); ?>
<a class="readmore" href="<?php the_permalink(); ?>">Read more &#187;</a>
</div>
<?php endwhile; ?>
@jerewall
jerewall / functions.php
Created February 13, 2015 21:14
Remove the admin bar from the front end of wordpress when logged in
// Remove the admin bar from the front end
add_filter( 'show_admin_bar', '__return_false' );
@jerewall
jerewall / functions.php
Created February 18, 2015 21:02
Sitemap for Menu
<h1>Sitemap</h1>
[menu name="Sitemap"]
/* Create shortcode to generate menu list in post */
/* Shortcode: [menu name="name-of-menu"] */
function print_menu_shortcode($atts, $content = null) {
extract(shortcode_atts(array( 'name' => null, ), $atts));
return wp_nav_menu( array( 'menu' => $name, 'echo' => false ) );
}
@jerewall
jerewall / style.css
Last active August 29, 2015 14:15
Duplicate Content Sections In Ecomm
/*The following will elimiate the padding in the extra content section*/
#page.content {
padding: 0px;
}
@jerewall
jerewall / functions.php
Last active August 29, 2015 14:16
How to execute PHP code in Text Widget without using Plugin
/* Sometimes we need to execute PHP scripts in text widget but by default WordPress doesn’t allow this feature because of
security issues.
Find the functions.php file of your current theme and add the following code at the end of the file.
*/
function php_execute($html){
if(strpos($html,"<"."?php")!==false){ ob_start(); eval("?".">".$html);
$html=ob_get_contents();
ob_end_clean();
}
@jerewall
jerewall / css.css
Last active August 29, 2015 14:16
Make the trailing 3d shadow on top navigations using CSS
/* Make the trailing 3d shadow on top navigations using CSS*/
.nav li {
content: "";
width: 0px;
height: 0px;
position: absolute;
bottom: -10px;
left: 0px;
border-width: 5px 5px 5px 5px;
border-style: solid;
@jerewall
jerewall / functions.php
Created March 13, 2015 18:35
Create a custom shortcode in wordpress using functions for any code
// reviews widget provided by customer
function shortcodenamehere_function() {
$text = <<<TEXT
(Insert any code here)
TEXT;
return $text;
}
add_shortcode('shortcodenamehere', 'shortcodenamehere_function');
// end shortcode creator