Skip to content

Instantly share code, notes, and snippets.

View krogsgard's full-sized avatar

Brian Krogsgard krogsgard

View GitHub Profile
@krogsgard
krogsgard / except-sass.scss
Created February 24, 2014 17:50
Is this the best way to do a "apply this except for this parent class" in Sass? Still required declaring twice, though the parent selector targeting thingy is really cool.
.hentry.featured {
border-bottom: 15px solid #f6f6f6;
padding-bottom: 1em;
.singular & {
border-bottom: 0;
padding-bottom: 0;
}
}
@krogsgard
krogsgard / [entry-modified] shortcode
Created February 12, 2012 19:13
Uses the get_the_modified_time function to created a shortcode, just like the [entry-published] shortcode in Hybrid Core
add_shortcode( 'entry-modified', 'krogs_entry_modified_shortcode' );
function krogs_entry_modified_shortcode( $attr ) {
$domain = hybrid_get_textdomain();
$attr = shortcode_atts( array( 'before' => '', 'after' => '', 'format' => get_option( 'date_format' ) ), $attr );
$modified = '<abbr class="modified" title="' . sprintf( get_the_modified_time( esc_attr__( 'l, F jS, Y, g:i a', $domain ) ) ) . '">' . sprintf( get_the_modified_time( $attr['format'] ) ) . '</abbr>';
return $attr['before'] . $modified . $attr['after'];
@krogsgard
krogsgard / wordpress-loop
Created February 20, 2012 04:45
The Basic WordPress Loop
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php // You can do stuff here to display aspects of the posts which meet the criteria of the current loop. ?>
<?php endwhile; else: ?>
<p><?php _e('The Loop did not find anything.'); ?></p>
<?php endif; ?>
@krogsgard
krogsgard / arcticle
Created February 21, 2012 02:06
Twenty Eleven Loop
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
@krogsgard
krogsgard / query-posts-page-template
Created March 7, 2012 05:07
query_posts in page template
<?php $args = array(
'post_type' => array ( 'post', 'page' ),
'posts_per_page' => 1,
'paged' => ( get_query_var('page') ? get_query_var('page') : 1 )
); ?>
<?php query_posts( $args ); ?>
<?php if ( have_posts() ) : ?>
<?php
/**
* Add function to widgets_init that'll load our widget.
* @since 0.1
*/
add_action( 'widgets_init', 'latest_load_widgets' );
/**
* Register our widget.
* 'Latest_Tweet_Widget' is the widget class used below.
@krogsgard
krogsgard / events-labels.php
Created June 22, 2012 16:03
Change The Events Calendar labels
<?php
add_filter( 'gettext', 'krogs_event_change_venue_name', 20, 3 );
/**
* Change comment form default field names.
*
* @link http://codex.wordpress.org/Plugin_API/Filter_Reference/gettext
*/
function krogs_event_change_venue_name( $translated_text, $text, $domain ) {
@krogsgard
krogsgard / standard-woocommerce-product-loop-html-output.html
Created June 29, 2012 04:59
markup desired for WooCommerce product loop
<li class="product">
<a href="http://wp.com/shop/product-title/">
<img width="150" height="150" src="http://wp.com/wp-content/uploads/2012/06/IMAGE-150x150.jpg" class="attachment-shop_catalog wp-post-image" alt="ACCUTACT ANGLESIGHT" title="ACCUTACT ANGLESIGHT">
<h3>Product Title</h3>
<span class="price"><span class="amount">&#36;250</span></span>
@krogsgard
krogsgard / placeholder-image-override.php
Created July 10, 2012 20:23
Little more dev-site friendly
<?php
/*
* goes in theme functions.php or a custom plugin
*
**/
add_filter('woocommerce_placeholder_img_src', 'custom_woocommerce_placeholder_img_src');
function custom_woocommerce_placeholder_img_src( $src ) {