Skip to content

Instantly share code, notes, and snippets.

View ajvillegas's full-sized avatar

Alexis J. Villegas ajvillegas

View GitHub Profile
@helen
helen / repeatable-fields-metabox.php
Created January 11, 2012 04:42
Repeating Custom Fields in a Metabox
<?
/**
* Repeatable Custom Fields in a Metabox
* Author: Helen Hou-Sandi
*
* From a bespoke system, so currently not modular - will fix soon
* Note that this particular metadata is saved as one multidimensional array (serialized)
*/
function hhs_get_sample_options() {
@ScottPhillips
ScottPhillips / .htaccess
Created February 2, 2012 04:30
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@pitch-gist
pitch-gist / gist:2999707
Created June 26, 2012 22:21
HTML: Simple Maintenance Page
<!doctype html>
<title>Site Maintenance</title>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }
</style>
@chrisguitarguy
chrisguitarguy / archive-menu-order.php
Created August 28, 2012 20:16
Force orderby to `menu_order` on a custom post type archive and a few custom taxonomy archives
<?php
add_action('parse_query', 'pmg_ex_sort_posts');
/**
* Hooked into `parse_query` this changes the orderby and order arguments of
* the query, forcing the post order on post type archives for `your_custom_pt`
* and a few taxonomies to follow the menu order.
*
* @param object $q The WP_Query object. This is passed by reference, you
* don't have to return anything.
* @return null
@karlstolley
karlstolley / rgba.scss
Created October 19, 2012 03:04
RGB/RGBa in Sass
// Declare the color as RGB; SASS will treat this as hex
$green: rgb(27,224,63);
// Declare an alpha
$alpha: .5;
// Declare another color variable as a color with an alpha
$greenAlpha: rgba($green, $alpha);
body {
/* As RGB (which SASS actually ouputs as HEX) */
background: $green;
@aghouseh
aghouseh / states and counties
Created October 21, 2012 07:10
PHP nested array of states and counties
$counties = array(
"Alabama" => array(
"Autauga County",
"Baldwin County",
"Barbour County",
"Bibb County",
"Blount County",
"Bullock County",
"Butler County",
"Calhoun County",
@irazasyed
irazasyed / Install Composer using MAMP's PHP.md
Last active August 6, 2024 16:43
Instructions on how to change preinstalled Mac OS X PHP to MAMP's PHP Installation and then install Composer Package Management

Change default Mac OS X PHP to MAMP's PHP Installation and Install Composer Package Management


Instructions to Change PHP Installation


First, Lets find out what version of PHP we're running (To find out if it's the default version).

To do that, Within the terminal, Fire this command:

which php

@natebot
natebot / is-meta-box-registered.php
Last active October 9, 2024 00:22
Test if a WordPress meta box has been registered.
<?php
/**
* Check if a meta box has been registered.
* Returns true if the supplied meta box id has been registered. false if not.
* Note that this does not check what page type
* @param String $meta_box_id An id for the meta box.
* @param String $post_type The post type the box is registered to (optional)
* @return mixed Returns boolean or a WP_Error if $wp_meta_boxes is not yet set.
*/
@hissy
hissy / functions.php
Created October 1, 2013 23:52
[WordPress/Filter] Exclude specific category from your blog
<?php
// Exclude 'example' category from your blog
function my_get_terms_args_exclude( $args, $taxonomies ) {
if (!is_admin()) {
$cat = get_category_by_slug( 'example' );
if ( is_object( $cat ) ) {
$args['exclude'] = $cat->term_id;
}
}
@WebEndevSnippets
WebEndevSnippets / functions.php
Created January 3, 2014 20:03
Genesis : Add comment count and remove standard comment title
add_action( 'genesis_before_comments' , 'webendev_comment_count' );
/**
* Add comment count and remove standard comment title
*
*/
function webendev_comment_count () {
add_filter( 'genesis_title_comments', '_return_null' );
if ( is_single() ) {
if ( have_comments() ) {
echo '<h3>';