Skip to content

Instantly share code, notes, and snippets.

@aaroncolon
aaroncolon / get-page-id-by-template.php
Last active July 4, 2020 04:04
WP get page ID by page template
/**
* Get Page ID by Template Name
* @param {string} full filename of template (e.g., full-width.php)
* @return {array} IDs of pages assigned the template
*/
function ac_get_id_by_template($templateName) {
$args = array(
'post_type' => 'page',
'fields' => 'ids',
'nopaging' => true,
@aaroncolon
aaroncolon / loader.php
Created February 13, 2019 20:51
All-In-One Events Calendar WP Engine 502 Error Fix (Interim)
<?php
/**
* Autoloader Class
*
* This class is responsible for loading all the requested class of the
* system
*
* @author Time.ly Network, Inc.
* @since 2.0
@aaroncolon
aaroncolon / ajax-retry.jquery.js
Created July 6, 2018 21:52
Retry AJAX request on error
(function() {
"use strict";
function doAjax(counter, callback) {
var attempt = counter || 0;
var retryLimit = 2;
jQuery.ajax({
type: 'GET',
url: '',
@aaroncolon
aaroncolon / async-ajax-abort.jquery.js
Last active July 6, 2018 21:37
Abort in-progress async AJAX requests
(function(){
"use strict";
var ajaxRequest = null;
/**
* Abort in-progress AJAX request
*/
function abortAjax() {
if (ajaxRequest && ajaxRequest.readyState != 4) {
function recursiveAjax(currPage, callback) {
var currPage = currPage || 1;
jQuery.ajax({
type : 'GET',
url : '',
dataType : 'json',
data : {
page : currPage
}
@aaroncolon
aaroncolon / archive-ac_films.php
Last active August 29, 2015 13:57
Dynamic Sort CPT
<?php
function ac_sort_buttons() {
echo '<p>';
echo 'Sort:';
echo '<a href="?sort=oldest">Oldest</a>';
echo '<a href="?sort=alpha">Alphabetical</a>';
echo '<a href="?sort=random">Random</a>';
echo '<a href="?sort=all">Show All</a>';
echo '</p>';