Skip to content

Instantly share code, notes, and snippets.

/* the lines of code that generates ALL checkbox fields*/
case 'checkbox':
echo '<input type="checkbox" name="'.$field['id'].'" class="'.$field['id'].'" id="'.$field['id'].'" ',$meta ? ' checked="checked"' : '','/>
<label for="'.$field['id'].'">'.$field['desc'].'</label>';
break;
/* the actual HTML output seems the same */
@LinzardMac
LinzardMac / gist:890ad53d971e4dd98139
Created February 11, 2015 17:48
Group content by first letter
<?php
/**
* Ajax Alphavet A-Z Post Loading
*
* @package WordPress
* @subpackage Twenty_Fifteen
* @since Twenty Fifteen 1.0
*/
/**
* List letters A-Z Based on posts in the database
$myposts = get_posts( $args );
$fri = date('Y-m-d',strtotime('friday this week'));
$sat = date('Y-m-d',strtotime('saturday this week'));
$sun = date('Y-m-d',strtotime('sunday next week'));
// one of the posts dumped in this has the "single date" array
var_dump($myposts);
//makes an array of IDs (which is always going to be an array of ONE ID
$location = array($_POST['cat']);
// var_dump($location);
// Add the content of the form to $post as an array
$post = array(
'post_title' => $title,
'post_content' => $description,
'post_date' => date('Y-m-d H:i:s'),
//does not throw error but doesnt update the taxonomy with the term selected
'tax_input' =>array( 'location' => array( $location ) ),
if( 'POST' == $_SERVER['REQUEST_METHOD']
) { // Check what the post type is here instead
// Setting the 'post_type' => $_POST['post_type'] in the $post array below causes 404
// Just set it based on what is set in the above IF $_POST type == 'book'.
// and below do 'post_type' => 'book'
// Do some minor form validation to make sure there is content
if (isset ($_POST['postTitle'])) { $title = $_POST['postTitle']; } else { echo 'Please enter a title'; }
if (isset ($_POST['postContent'])) { $description = $_POST['postContent']; } else { echo 'Please enter the content'; }
foreach($var as $img):
$img=$img['ID'];
$newimg = wp_get_attachment_link($img, 'full');
$i = 0;
?>
<li id="<?php echo $img[number];?>"><?php echo $newimg; ?></li>
<?php
$date_start = strtotime('first day of next month');
$end_date = strtotime("last day of next month", $date_start);
while ($date_start <= $end_date) :
$weekdates[] = date("Y-m-d", $date_start);
$date_start = strtotime('+1 day', $date_start);
endwhile;
foreach ( $weekdates as $days):
@LinzardMac
LinzardMac / gist:348feff3726ab89d8b72
Created January 8, 2015 17:42
Get IG photos with specific hashtag and display only from certain username.
function callInstagram($url)
{
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => 2
));
@LinzardMac
LinzardMac / gist:8924043
Created February 10, 2014 20:59
Adding taggable items in autocomplete
if ( 'multi' == pods_var( 'pick_format_type', $options ) && 1 != $pick_limit && taggable='true') {
tags: true,
createSearchChoice: function(term, data) {
if ($(data).filter(function() {
return this.text.localeCompare(term) === 0;
}).length === 0) {
return {
id: term,
text: term
};