Skip to content

Instantly share code, notes, and snippets.

.tabs{
margin: {top:40px;}
&:last-child{
margin: {bottom:80px;}
}
h2{
color: $color-1;
font: {
size: emCalc(36px);
}
<?php $the_query = new WP_Query('cat=3&posts_per_page=2'); ?>
<?php if ($the_query->have_posts()) : ?>
<?php while ($the_query->have_posts()) : $the_query->the_post(); ?>
output...
<?php endwhile; wp_reset_postdata();?>
<?php endif; ?>
@zenman
zenman / snippet.js
Last active December 19, 2015 15:39
var scrollToAnchor = function() {
//cache some variables
var scrollElement = 'html, body',
$window = $(window);
//grab all the anchor links
$("a[href^='#']").click(function(e) {
//stop immediate scroll
e.preventDefault();
<?php
/*
* Use Parent Category
* Description: Causes subcategories to use their parent's template
*/
function load_cat_parent_template(){
global $wp_query;
if (!$wp_query->is_category) {
return true; // saves a bit of nesting
<?php
//hostname based google code, only run if on live site - Tom Horak
//placed right before closing body tag according to google best practice: http://support.google.com/googleanalytics/bin/answer.py?hl=en&answer=55488
//moved to right before closing head tag per SEOverflow 05/25/12
$hostname = $_SERVER['HTTP_HOST']; //dev.zenman.com | localhost | Live server | etc..
switch ($hostname) {
case 'localhost': //do nothing
//echo '<!-- no google analytics code -->';
break;
@zenman
zenman / snippet.php
Created January 8, 2013 04:12
Add div section within the_content() as a short code
<?php
/*
* Add div section within the content as a short code.
*
* This allows users to edit content in visual mode without stripping
* out necessary but hidden <div> tags.
*
* Example usages:
* [section]My Content[/section] = <div>My Content</div>
* [section width='6']My Content[/section] = <div class="col6">My Content</div>
@zenman
zenman / snippet.php
Created January 8, 2013 04:07 — forked from tcmulder/wp-old-content-debugger.php
Set up faux the_content() simulation
<?php
/**
* Set up faux the_content() simulation
*
* You can use this to simulate the_content() through a shortcode. Simply
* add the shortcode [faux] on any page in wp-admin and publish. Then,
* Then, make all your changes in your favorite text editor in the includes/faux-content.php
* file. Once finished, paste the contents of includes/faux-content.php into the page in wp-admin.
*/
function faux_the_content_() {
@zenman
zenman / snippet.php
Last active December 10, 2015 19:28
Remove empty <p> tags from the_content() input
<?php
/*
* Remove empty <p> tags from the_content() input
*
*/
add_filter('the_content', 'remove_empty_p', 20, 1);
function remove_empty_p($content){
$content = force_balance_tags($content);
return preg_replace('#<p>\s*+(<br\s*/*>)?\s*</p>#i', '', $content);
}