Skip to content

Instantly share code, notes, and snippets.

View lewismcarey's full-sized avatar

Lewis Carey lewismcarey

  • ThirtyThree
  • London, UK
View GitHub Profile
@lewismcarey
lewismcarey / WORDPRESS Oldest Post Date
Last active August 29, 2015 13:56
WORDPRESS Oldest Post Date
# WORDPRESS Oldest Post Date
This function gets the oldest post's published date (status published).
* You must pass it a post type (accepts Custom Post Types)
* You may pass it a date format (http://www.php.net/manual/en/function.date.php)
## Usage
echo oldest_post_date( 'post' );
@lewismcarey
lewismcarey / WORDPRESS Live Preview
Last active January 4, 2016 06:09
Create WordPress preview whilst maintaining a holding page.
# WORDPRESS Live Preview
This wrapper allows you to maintain a HTML holding page whislt seetting up a preview of a live WP site.
This is handy if you tend to work locally and don't intend to set up a remote test environment.
## Usage
http://www.yourwebsite.com?preview=allow
http://www.yourwebsite.com?preview=end
@lewismcarey
lewismcarey / Open Graph
Created January 23, 2014 14:46
Open Graph WIP
<!-- OG -->
<meta property="og:name" content="<?php echo bloginfo( 'name' ); ?>" />
<meta property="og:type" content="website" />
<meta property="og:title" content="<?php the_title(); ?>" />
<meta property="og:url" content="<?php the_permalink(); ?>" />
<meta property="og:image" content="path/to/avatar.png" />
<meta property="og:image:width" content="200" />
<meta property="og:image:height" content="200" />
@lewismcarey
lewismcarey / blackandwhiteimages.php
Created April 12, 2012 16:40
Generate B + W images in WordPress
<?php
/* using thumbnail */
add_filter('wp_generate_attachment_metadata','bw_images_filter');
function bw_images_filter($meta) {
$file = wp_upload_dir();
$file = trailingslashit($file['path']).$meta['sizes']['thumbnail']['file'];
list($orig_w, $orig_h, $orig_type) = @getimagesize($file);
$image = wp_load_image($file);
imagefilter($image, IMG_FILTER_GRAYSCALE);