finally took care of a nagging part of my site… the top slideshow. it wasn’t responsive before and now it is

it’s based off the responsive slider plugin. i had to make a minor change to it so it would show six slides per page load, choosing randomly from the library of slides. by default, it would show x amount of slides, where x is set in the settings > reading section (“Blog pages show at most”)

default

$slides = new WP_Query( array( 'post_type' => 'slides', 'order' => 'ASC', 'orderby' => 'menu_order' ) );

updated

$slides = new WP_Query( array( 'post_type' => 'slides', 'order' => 'ASC', 'orderby' => 'rand', 'posts_per_page' => 6 ) );

i actually didn’t expect the 'orderby' => 'rand' part to do what it did (choose randomly from the library of slides), but i’m pretty happy with it. this way, i can upload as many slides and not have to worry about ordering them in any special way

'posts_per_page' => 6 is what controls the amount of slides that are shown in the slideshow

yes, i’m aware that this will be killed if i update the plugin…

video of matt doing a baserunning drill.

he had to hit the ball, then two other players on the other team (posted up on first and third base) had to run after and touch the ball. when both “defenders” touched the ball, the baserunner was out and the total bases touched were counted (that’s why you hear “three!”

the $wpdb object is crazy powerful. with it, you can access almost anything in your database

this is extremely helpful when doing plugin development…

recently at work, i was tasked to do this project:

  • create a wordpress plugin that requires a separate database table
  • the table will house data imported from several excel files
  • admin will be able to add/edit/delete entries
  • create a template that will display the data, dropdowns will help filter information: date, location
  • sort by date, then event name

$wpdb was used heavily in this plugin and it works well

Read more »

i’ve added a new feature to my site: custom post types. you can see the page here — as you can see, it’s all of my sketches i’ve done since last august

code

functions.php
first add this to allow for featured images (if it’s not already in there):

add_theme_support( 'post-thumbnails' );

This part will register the custom post type to wordpress

add_action( 'init', 'create_sketch' );
function create_sketch() {
$labels = array(
'name' => _x('Sketches', 'post type general name'),
'singular_name' => _x('Sketch', 'post type singular name'),
'add_new' => _x('Add New Sketch', 'Sweet'),
'add_new_item' => __('Add New Sketch'),
'edit_item' => __('Edit Sketch'),
'new_item' => __('New Sketch'),
'view_item' => __('View Sketch'),
'search_items' => __('Search Sketches'),
'not_found' => __('No Sketches found'),
'not_found_in_trash' => __('No Sketches found in Trash'),
'parent_item_colon' => ''
);

$supports = array('title', 'editor', 'revisions', 'thumbnail', 'comments');

register_post_type( 'sketches',
array(
'labels' => $labels,
'public' => true,
'supports' => $supports
)
);
}

Read more »

all hail the latest meme to capture the hearts of the internet: grumpy cat:

Grumpy-Cat-MEME-01

so here’s my little sketch:

grumpycat

download the pdf to print out!

Read more »

originally found this on josh stauffer’s site. just wanna add to my site so i can pull it up easily

$slug = basename(get_permalink());

needed to do this to make wordpress choose the thumbnail image instead of the full-sized image — since some people like to upload gernormous images (recall that wordpress uploads a whole set of images when you upload one)

so this adds a suffix (in this case, “-150×150”) to the of the filename, BUT before the file extension

anyway, here it is:

// set your suffix
$thumbnail_suffix = "-150x150";

// $featured_image is the filename. this would be determined above this code snippet
// determine the length of the filename, including the extension
$length = strlen ($featured_image);

// get the first part of the filename (before the extension)
$temp1 = substr ($featured_image, 0, $length-4);

// get the second part of the filename (the extension)
$temp2 = substr ($featured_image, $length-4, $length);

// stick the suffix in between the two halves
$featured_image_updated = $temp1.$thumbnail_suffix.$temp2;

you might be saying, “but joey.. why don’t you just use something like explode to break up the filename?” well you really don’t know what the filename will be — it could have a bunch of dots in it… if you could figure it out, great. let me know what you did.

at least you know every image file that’ll be uploaded will be a “.” and then three characters after.

tried this out the other day… dennis’ recipe — i’d marinate the meat — preferably flap meat — overnight

Ingredients

  • fresh cracked pepper
  • flap meat (best deal is at costco)
  • 1 lemon — halved and squeezed
  • ½ garlic — finely chopped
  • korean bbq marinade — this can be purchased at any grocery store in the asian aisle
  • heavily season with salt and pepper
  • 1 can sprite
Read more »

was challenged at work and couldn’t think of a proper solution. i knew it was possible, but didn’t know how to execute it

this is what happens when you don’t know all the tools you have available to you…

thank god for the wordpress community

background

this makes absolutely no sense without any background! essentially i have a splash page that goes to several sub-sites. when you get to a sub-site, i want each sub-site’s home to go back to its own home location, not the splash page, which would be

< ?php echo get_option('home'); ?>

code

< ?php //parent variables
	$parent = get_post($post->post_parent);
	$parent_title = get_the_title($parent);
	$grandparent = $parent->post_parent;
	$grandparent_title = get_the_title($grandparent);?>

	< ?php // is the homepage the granparent?
	if ($grandparent == is_page('0')) { ?>
	<li><a href="/<?php echo get_permalink($grandparent); ?>">Back to < ?php echo $grandparent_title; ?></a></li>
	<li><a href="<?php echo get_permalink($post->post_parent); ?>">Back to < ?php echo $parent_title; ?></a></li>

	< ?php // is the homepage the parent?
	} elseif ($post->post_parent ==is_page('0')) {?>
   <li> <a href="<?php echo get_permalink($post->post_parent) ?>">Back to < ?php echo $parent_title; ?></a></li>

    < ?php // I must be a top level page!
	} else { ?> <!-- no parent to show -->
< ?php }?>