Skip to content

Instantly share code, notes, and snippets.

@jonathanhudak
jonathanhudak / Wordpress List Recent Posts Excluding Current Post
Created April 27, 2013 20:15
A snippet to list recent posts with their post thumbnail on the Single.php template, which excludes the current Single Post.
<div class="recent-post-list">
<?php
$the_query = new WP_Query(array('showposts' => 5, 'orderby' => 'post_date', 'order' => 'desc', 'offset' => 1, 'post__not_in' => array( $post->ID )));
while ($the_query->have_posts()) : $the_query->the_post(); ?>
<div class="recent-post">
<a title="<?php the_title(); ?>" href="<?php the_permalink() ?>" rel="bookmark">
<?php the_post_thumbnail(array(50,50, true), array ('')); ?>
<h3><?php the_title(); ?></h3>
</a>
<div class="clear"></div>
$post_image_url = $post_image[0];
$the_content = get_the_content();
$content_cleaned = strip_shortcodes( $the_content );
$new_excerpt = wp_trim_words( $content_cleaned, 35 );
$json_posts[] = array('title' => get_the_title(),'content'=>get_the_content(), 'excerpt'=>$new_excerpt, 'url'=>get_permalink(get_the_ID()), 'thumbnail'=>$post_image_url, 'post_class'=>$postClass);
@jonathanhudak
jonathanhudak / gist:7033217
Created October 17, 2013 22:14
triangle mixins
@mixin triangle($direction:up, $color:#000, $size:100px) {
@if($direction == up) {
border-color: transparent transparent $color;
border-style: solid;
border-width: 0 $size $size;
height: 0;
width: 0;
}
@if($direction == down) {
border-color: $color transparent transparent transparent;
@jonathanhudak
jonathanhudak / gist:7033237
Created October 17, 2013 22:15
Double border
@mixin trim-border($thinColor, $thickColor) {
box-shadow:
0 0 0 1px $thinColor,
0 0 0 9px $thickColor;
//@include box-sizing(content-box);
}
//functions.php
wp_register_script('livereload', 'http://localhost:35729/livereload.js?snipver=1', null, false, true);
wp_enqueue_script('livereload'); //keep this at the bottom
// this code creates a variable for your template assets path for use with require.js
$WP_DIRECTORY = array( 'path' => get_stylesheet_directory_uri() . '/js' );
wp_localize_script( 'require', 'directory', $WP_DIRECTORY );
@jonathanhudak
jonathanhudak / A-Pen-by-Jonathan-Hudak.markdown
Created November 13, 2013 05:17
A Pen by Jonathan Hudak.
@jonathanhudak
jonathanhudak / gist:8305736
Created January 7, 2014 19:53
sharer links
<a class="share-icon share-icon-email pop" href="mailto:?subject=<?php echo urlencode(the_title()); ?>&body=<?php the_permalink(); ?>" title="Send a link to this post via email" rel="nofollow">Share this post via email</a>
<a class="share-icon share-icon-facebook pop" href="http://www.facebook.com/sharer/sharer.php?u=<?php echo get_permalink(); ?>&t=<?php echo get_the_title(); ?>" target="_blank" title="Share This on Facebook">fb</a>
<a class="share-icon share-icon-twitter pop" href="http://twitter.com/share?text=<?php echo urlencode(the_title()); ?>&url=<?php echo urlencode(the_permalink()); ?>&via=twitter" title="Share on Twitter" rel="nofollow" target="_blank">Tweet This</a>
<a class="share-icon share-icon-tumblr pop" href="http://www.tumblr.com/share/link?url=<?php echo urlencode(get_permalink()) ?>&name=<?php echo urlencode(get_the_title()) ?>&description=<?php echo urlencode(the_excerpt()) ?>" target="_blank" title="Share on Tumblr">Share on Tumblr</a>
@jonathanhudak
jonathanhudak / edit.html
Created March 1, 2016 16:36
Closures and HTTP Routing/Templates
<h1>Editing {{.Slug}}</h1>
<form action="/save/{{.Slug}}" method="POST">
<div><textarea name="body" rows="20" cols="80">{{printf "%s" .Body}}</textarea></div>
<div><input type="submit" value="Save"></div>
</form>
#!/bin/sh
mysqldumpdb() {
if [ -z "$1" ]
then
echo "Specify mysql database name as parameter #1"
else
now=$(date +"%s")
cmd="mysqldump -uroot -proot $1 | gzip > /Users/jonathan/Desktop/$1-$now.sql.gz"
echo $cmd
eval $cmd