Skip to content

Instantly share code, notes, and snippets.

@ammist
ammist / tl-cf7-captcha.html
Created May 16, 2011 00:20
Contact Form 7 with Captcha
<p>Your Name (required)<br />
[text* your-name] </p>
<p>Your Email (required)<br />
[email* your-email] </p>
<p>Subject<br />
[text your-subject] </p>
<p>Your Message<br />
[textarea your-message] </p>
<p class="captcha">
Enter the following phrase in the text box below:
@ammist
ammist / wp-custom-post-type.php
Created June 15, 2011 17:03
[WP] Create a Custom Post Type
register_post_type('book', array('label' => 'Books',
'description' => 'Books and other items for sale on the Heyday website',
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'capability_type' => 'post',
'hierarchical' => false,
'rewrite' => array('slug' => ''),
'query_var' => true,
'supports' => array('title','editor','excerpt','custom-fields','revisions','thumbnail','author','page-attributes',),
@ammist
ammist / svn_overwrite.sh
Created June 29, 2011 08:23 — forked from doolin/svn_overwrite.sh
[WP] [SVN] - Getting WordPress out of SVN
#!/usr/bin/sh
# This script will overwrite an existing
# WordPress installation with the current
# head of trunk. Once it has been reverted,
# you may need to update the database, and
# WP will prompt you for that automatically.
# This is untested with these options!
# The script commands work from the command
@ammist
ammist / change_urls.sql
Created August 31, 2011 07:28
MySQL Wrangling
-- handy for moving a database from prouction to your local environment.
-- change URL's in wordpress single-site install. Replace with your own URL's.
-- this doesn't address serialized options.
UPDATE wp_options SET option_value = "http://localhost:8888" WHERE option_name = "home";
UPDATE wp_options SET option_value = "http://localhost:8888" WHERE option_name = "siteurl";
update wp_postmeta set meta_value = replace(meta_value, 'http://example.com', 'http://localhost:8888') where meta_key='_menu_item_url';
update wp_posts set post_content = replace(post_content, 'http://example.com', 'http://localhost:8888');
@ammist
ammist / gist:1252863
Created September 30, 2011 06:22
[WP] Install WP quickly
# This script is for shell users who have previously created a database.
mkdir ~/installs
cd ~/installs
wget http://wordpress.org/latest.zip
unzip latest.zip
cp wordpress/* ~/public_html/
cd ~/public_html/
cp wp-config-sample.php wp-config.php
vi wp-config.php
@ammist
ammist / wp-common-queries.sql
Created December 22, 2011 00:57
WordPress SQL queries I use a lot
-- Life is better when you can cut and paste
-- Post meta
-------------
-- Site Options
-------------
select distinct option_name from wp_options;
@ammist
ammist / attach_category.php
Last active October 11, 2015 22:58
WordPress: Attach a category of posts to a page or other post
/* if using this with Genesis, hook this after the loop.
The name of the custom field can be hidden, if you provide a metabox for choosing it.
The simplest thing is to leave it visible and just use the custom field selector.
*/
function tl_attach_category(){
global $post;
$attach_option = get_post_meta($post->ID, 'attach_category', true);
// You might want to do different things for different categories
@ammist
ammist / google_maps_sample.html
Created March 1, 2013 20:24
Google Map with Two Markers
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<title>Google Maps JavaScript API v3 Example: Marker Simple</title>
<link href="https://developers.google.com/maps/documentation/javascript/examples/default.css" rel="stylesheet">
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
<script>
function initialize() {
@ammist
ammist / genesis_event_calendar_page.php
Created June 6, 2013 01:54
If you are using the Events Calendar PRO with Community events submission with Genesis, you may run into an issue where the submission form is replicated in other widget areas where you are including posts or pages with content. This updated template file can be used to avoid this problem. Just save this code as page.php in your child theme. Thi…
<?php
/* When we're using the event calendar community feature, we need to disable any
widget areas that might be displaying extra copies of the form. In theory Modern
Tribe will fix this in a future release, but, in the meantime... */
function check_for_event_calendar_pro_router_page(){
global $wp_query;
<!-- replace the below with this -->
<a href="<?php echo esc_url( home_url( '/' ) ); ?>">
<?php if (is_category(1)){ ?>
<img src="http://asdfha.jpg" class="header-image" width="" height="" alt="Header 5" />
<?php } else {
$header_image = get_header_image(); ?>
<img src="<?php echo esc_url( $header_image ); ?>" class="header-image" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="" />
<?php } ?>
</a>