Skip to content

Instantly share code, notes, and snippets.

@srobbin
srobbin / gist:3799775
Created September 28, 2012 13:15
Random Backstretch image
<script>
// Create an array of images that you'd like to use
var images = [
'image1.jpg'
, 'image2.jpg'
, 'image3.jpg'
];
// Get a random number between 0 and the number of images
var randomNumber = Math.floor( Math.random() * images.length );
@reesmcivor
reesmcivor / wordpress_json_posts
Created August 20, 2012 10:15
wordpress_json_posts
<?php
// include our wordpress functions
// change relative path to find your WP dir
define('WP_USE_THEMES', false);
require('./wp-blog-header.php');
// set header for json mime type
header('Content-type: application/json;');
$.fn.setAllToMaxHeight = function(){
return this.height( Math.max.apply(this, $.map( this , function(e){ return $(e).height() }) ) );
}
// usage: $(‘div.unevenheights’).setAllToMaxHeight();
@claudiosanches
claudiosanches / functions.php
Created July 24, 2012 03:22
Wordpress Related Posts function
<?php
/**
* Related Posts.
*
* Usage:
* To show related by categories:
* Add in single.php <?php dfw_related_posts(); ?>.
* To show related by tags:
* Add in single.php <?php dfw_related_posts('tag'); ?>.
@gyrus
gyrus / preload-images.js
Last active March 3, 2021 11:57
WordPress image preloading
/**
* Image preloader
*
* @link http://engineeredweb.com/blog/09/12/preloading-images-jquery-and-javascript
*/
var cache = [];
// Arguments are image paths relative to the current page.
function pilau_preload_images() {
var args_len, i, cache_image;
args_len = arguments.length;
@ekka21
ekka21 / gist:3018426
Created June 29, 2012 14:52
Wordpress: Using wordpress call Ajax the right way
jQuery.ajax({
url: '/wp-admin/admin-ajax.php',
type: 'GET',//POST, JSON, XML
dataType: 'html',
data: ({
action: 'MY_AJAX_FUNCTION',
state: state,
}),
success: function(data){
if (data){
@claudiosanches
claudiosanches / index.php
Created June 29, 2012 04:44
Display modified date - Wordpress
<!-- Mostra a data como: 28/06/2012 às 01h44 -->
<div class="entry-modified-data"><?php the_modified_date('d/m/Y \à\s H\hi'); ?></div>
@manojsinghrwt
manojsinghrwt / mswp.php
Created June 27, 2012 05:14
WordPress MS Framework
<?php
/*
* WP MS Framework 1.0
* Version 1.0
* Developed By Manoj Singh
* Note: The another supported file is under-development
*/
/*
[1] get_wp_ms_excerpt($content,$size);
@coreyweb
coreyweb / gist:2718955
Created May 17, 2012 13:33
WordPress Popular Comments
<?php
/**
* Display a list of the 10 most commented posts (WordPress)
* @author Corey Brown https://github.com/coreyweb
* @author Aaron Collegeman: https://github.com/collegeman
* @author Joey Blake: https://github.com/joeyblake
*
* Rules:
* - show a list of 10 posts
* - published any time
@murdaugh
murdaugh / gist:2714140
Created May 16, 2012 21:37
Flickr JSON PHP
<?php
echo flickr_feed('http://api.flickr.com/services/feeds/photos_public.gne?id=12345678@N06&format=json&nojsoncallback=1');
function flickr_feed($url) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);