Skip to content

Instantly share code, notes, and snippets.

View avclark's full-sized avatar

Adam Clark avclark

View GitHub Profile
@avclark
avclark / gist:10401914
Last active August 29, 2015 13:58
Wordpress Offset
<?php get_header(); ?>
<?php
$number_of_feature_posts = 1;
$number_of_secondary_posts = 8;
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$how_many_secondary_posts_past = ($number_of_secondary_posts * ($paged - 1));
$off = $number_of_feature_posts + (($paged > 1) ? $how_many_secondary_posts_past : 0);
?>
@avclark
avclark / wp_head cleanup
Created May 3, 2014 04:26
Cleanup unnecessary code from wp_head by adding this code to functions.php
<?php
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'wp_generator');
remove_action('wp_head', 'start_post_rel_link');
remove_action('wp_head', 'index_rel_link');
remove_action('wp_head', 'adjacent_posts_rel_link');
?>
add_filter( 'pre_get_posts', 'my_get_posts' );
function my_get_posts( $query ) {
if ( is_home() && $query->is_main_query() )
$query->set( 'post_type', array( 'Resources' ) );
return $query;
}
@avclark
avclark / presale app
Created December 25, 2014 00:21
presale app jquery modifications
// Here are some of the changes I made to these two functions, but this broke the whole, I was getting an error saying something like unidentified param: amount, so something like that.
function populateCurrentPrice(price) {
$('.currentPrice span').text(price/100);
$('#customButton span').text(price/100);
$('#currentPurchases').text( (price/100) -1);
$('#customButton').off('click');
$('#customButton').on('click', function(e) {
handler.open({
amount: price
@avclark
avclark / wp-cpt
Created May 11, 2012 13:16
Wordpress Custom Post Type
register_post_type('floorplans', array(
'label' => __('Floorplans'),
'singular_label' => __('Floorplans'),
'public' => true,
'show_ui' => true,
'capability_type' => 'post',
'hierarchical' => false,
'rewrite' => true,
'query_var' => false,
'supports' => array('title', 'editor', 'author'),
@avclark
avclark / Create new base project
Created September 30, 2012 17:25
Bash script to automate new project creation using Alfred, Github and Beanstalk
# Create Beanstalk Repository
printf "git\n \n" | /Users/avclark/beanstalk repo:create {query}
# Create our new project directory
cd ~/desktop && mkdir {query} && cd {query}
# Clone our HTML-Base repo from Github
git clone https://github.com/avclark/HTML-Base.git
# Cleanup directory
@avclark
avclark / gist:4072742
Created November 14, 2012 15:24
Simple PHP Contact Script
<?php
if(isset($_POST['email'])) {
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "email@yourdomain.com";
$email_subject = "Email Subject line";
function died($error) {
?>
@avclark
avclark / gist:7503165
Created November 16, 2013 17:47
Multi-environment config.php for Wordpress
<?php
/**
* The base configurations of the WordPress.
*
* This file has the following configurations: MySQL settings, Table Prefix,
* Secret Keys, WordPress Language, and ABSPATH. You can find more information
* by visiting {@link http://codex.wordpress.org/Editing_wp-config.php Editing
* wp-config.php} Codex page. You can get the MySQL settings from your web host.
*
* This file is used by the wp-config.php creation script during the
@avclark
avclark / gist:7514123
Created November 17, 2013 14:36
Vertically center block elements
// We use this to vertically center block elements
.vertical-center {
&:before {
content: '';
display: inline-block;
height: 100%;
vertical-align: middle;
margin-right: -0.25em; /* Adjusts for spacing */
}
div {
@mixin rem( $property, $a:0, $b:$a, $c:$a, $d:$b ) {
@if ( $property == "font-size" ) {
// $a is the font size
// %b is the keyword
@if ( $a != $b ) {
font-size: $b;
}
@else {
font-size: $a * $base-font-multiplier * 16px;
}