Skip to content

Instantly share code, notes, and snippets.

@sguzik
sguzik / BI Tumblr - Mods
Created November 7, 2011 19:44
Psudo Code Description
//Psudo Code Description
$url = LOAD Tumblr Posts from API
$xml = CREATE ARRAY from $url
$i = 0 //create a counter
foreach( $xml->ONEPOST as $post ){ //create loop to process individual posts
if ( $i LESS THAN 1 ) {
@sguzik
sguzik / gist:1346017
Created November 7, 2011 20:12
Brooklyn Ink Tumblr Mods (real code)
<?php
$url = 'http://thebrooklynink.tumblr.com/api/read/'; //where you can find the posts
$xml = simplexml_load_file($url); //parse the tumblr API to get an object containing all of your posts
$i = 0; //create a counter
foreach( $xml->posts->post as $post ){ //create loop to process individual posts
if ( $i < 1 ) { //check that the loop hasn't run before
@sguzik
sguzik / gist:1498804
Created December 19, 2011 20:49
WordPress Query for Tahiat
<?php
// Adapted from the first example on:
// http://codex.wordpress.org/Function_Reference/get_posts
global $post;
$args = array( 'numberposts' => 1, 'category' => 17 );
$video_posts = get_posts( $args );
foreach( $video_posts as $post ) : setup_postdata($post); ?>
<?php the_content(); ?>
<?php endforeach; ?>
@sguzik
sguzik / Brooklyn Ink Tumblr Widget
Created January 30, 2012 19:03
A simple widget for displaying posts from a tumblr widget.
<?php
/*
Plugin Name: Brooklyn Ink Tumblr Widget
Plugin URI: http://thebrooklynink.com
Description: A simple widget for displaying posts from a tumblr widget.
Author: Sam Guzik
Version: 1.0
Author URI: http://samguzik.com
*/
@sguzik
sguzik / gist:2472968
Created April 23, 2012 18:41
HTML wireframe for wordpress lesson
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Index page</title>
<meta name="description" content="">
<link rel="stylesheet" href="http://samguzik.com/wp_lesson/wp-content/themes/basicTheme/style.css">
<link rel="stylesheet" href="http://samguzik.com/wp_lesson/wp-content/themes/basicTheme/custom.css">
@sguzik
sguzik / gist:2482468
Created April 24, 2012 18:36
Starter for an HTML page
<!doctype html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<title>My Site</title>
</head>
<body>
</body>
</html>
@sguzik
sguzik / gist:2569959
Created May 1, 2012 17:43
Add thumbnails to our index page
<?php
if ( has_post_thumbnail() ) {
the_post_thumbnail();
}
?>
@sguzik
sguzik / gist:2569684
Created May 1, 2012 17:08
Getting theme details to show up in your stylesheet
/*
Theme Name: THEME_NAME_GOES_HERE
Theme URI: WHERE_DOES_THE_THE_THEME_LIVE
Description: DESCRIBE_THE_THEME
Author: YOUR_NAME_SCREENAME_WORDPRESS_USERNAME_OR_SOMETHING_ELSE
Author URI: YOUR_URL
Version: VERSION
Tags: DESCRIPTIVE TAGS
License:
@sguzik
sguzik / gist:2569719
Created May 1, 2012 17:12
The most basic PHP loop
/* The loop starts here:
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
/* and ends here:
<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
@sguzik
sguzik / gist:2569783
Created May 1, 2012 17:20
A sample WordPress loop
<!-- Start the Loop. -->
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<!-- This gives a DIV that will go around the post. -->
<!-- We're giving it a specific id and classes so you can style everything. -->
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?> >
<!-- Display the Title as a link to the Post's permalink. -->
<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>