Skip to content

Instantly share code, notes, and snippets.

http://wordpress.org/support/topic/how-to-add-four-wp-queries-without-duplicate-posts
query for loop1
loop1:
$do_not_duplicate[] = $post->ID;
end loop1;
query for loop2 including 'post__not_in => $do_not_duplicate'
loop2:
$do_not_duplicate[] = $post->ID;
@johnbhartley
johnbhartley / author check
Created January 14, 2013 19:46
WordPress author check.
<?php if(get_the_author() == 'admin') {
echo 'admin';
} else {
comments_template();
} ?>
@johnbhartley
johnbhartley / Twitter JSON with jQuery
Created February 7, 2013 17:29
The script used to grab Twitter JSON from the API and output into list items. Also includes a sexy loading gif.
var twitter_api_url = 'http://search.twitter.com/search.json';
var twitter_user = 'onebeatchannel';
$.ajaxSetup({
cache: true
});
$.getJSON(
twitter_api_url + '?callback=?&rpp=3&q=from:' + twitter_user,
@johnbhartley
johnbhartley / gist:5005299
Last active December 14, 2015 01:19
Public MG Pagination
<?php
//grabbed from image.php in TwentyTwelve...credit where credit's due
/**
* Grab the IDs of all the image attachments in a gallery so we can get the URL of the next adjacent image in a gallery,
* or the first image (if we're looking at the last image in a gallery), or, in a gallery of one, just the link to that image file
*/
$attachments = array_values( get_children( array( 'post_parent' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID' ) ) );
foreach ( $attachments as $k => $attachment ) :
if ( $attachment->ID == $post->ID )
@johnbhartley
johnbhartley / Unclickable links
Created May 30, 2013 20:17
Make links unclickable through jQuery...quick fix, but probably not the best way
@johnbhartley
johnbhartley / gallery-id-grabber
Created September 23, 2014 17:43
use gallery ids to output however you want.
@johnbhartley
johnbhartley / rrssb-counts
Created December 10, 2014 19:33
Tie share count into WordPress and RRSSB
<?php
require("share-count.php");
// grab current url by site, then inner page
$url = site_url() . $_SERVER['REQUEST_URI'];
// get page title and sanitize
$title = get_the_title();
$clean_title = str_replace(' ', '%20', $title);
const cards = [
'A',
'K',
'Q',
'J',
'10',
'9',
];