Skip to content

Instantly share code, notes, and snippets.

View dcooney's full-sized avatar

Darren Cooney dcooney

View GitHub Profile
@dcooney
dcooney / excerpt.php
Last active November 28, 2021 17:28
Custom Excerpt
<?php
// Get custom excerpt
function alm_get_excerpt($limit = 40, $after = null) {
$excerpt = explode(' ', get_the_excerpt(), $limit);
if (count($excerpt)>=$limit) {
array_pop($excerpt);
$excerpt = implode(" ",$excerpt).'...';
} else {
$excerpt = implode(" ",$excerpt);
}
@dcooney
dcooney / front.js
Created October 18, 2021 13:26
EZ TOC JS
jQuery( function( $ ) {
/**
* @typedef ezTOC
* @type {Object} ezTOC
* @property {string} affixSelector
* @property {string} scroll_offset
* @property {string} smooth_scroll
* @property {string} visibility_hide_by_default
*/
@dcooney
dcooney / single.php
Last active October 23, 2021 01:29
Generate Single Template
<?php
/**
* The Template for displaying all single posts.
*
* @package GeneratePress
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
get_header(); ?>
@import url('https://use.typekit.net/oen5jod.css');
@tailwind base;
@tailwind components;
@tailwind utilities;
/* Default Template Styles Start */
body {
&.no-scroll {
@dcooney
dcooney / functions.php
Created August 16, 2021 13:17
ALM Filters - Default Archive Query
<?php
function my_alm_filter_query_args( $args ){
// Get the archive query object.
$queried_obj = get_queried_object();
// Confirm archive and query object is available.
if ( is_archive() && $queried_obj && isset( $queried_obj->taxonomy ) ) {
// The default taxonomy query.
@dcooney
dcooney / experimental-theme.json
Last active January 19, 2021 20:20
Experimental Theme
{
"global":{
"settings":{
"color":{
"custom":false,
"customGradient":false,
"gradients":[],
"link":false,
"palette":[]
},
@dcooney
dcooney / content-single.php
Created January 16, 2021 14:06
GeneratePress Single Template
<?php
/**
* The template for displaying single posts.
*
* @package GeneratePress
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
<?php
global $sitepress;
$current_lang = $sitepress->get_current_language(); //save current language
$sitepress->switch_lang('en');
/*
* WP_Query
*
* @return $alm_query;
@dcooney
dcooney / category.php
Last active October 16, 2020 13:27
Genesis Archive with Ajax Load More
<?php
/**
* Genesis Framework.
*
* Custom Archive Template.
*
* @package Genesis\Templates
* @author ConnektMedia
* @license GPL-2.0+
* @link http://my.studiopress.com/themes/genesis/
@dcooney
dcooney / flatpickr_ext.js
Created October 7, 2020 12:56
Ajax Load More - flatpickr - disable past dates
<?php
// Add this hook to functions.php
add_action( 'wp_footer', function() {
?>
<script>
var alm_flatpickr_opts = {
disable: function(selectedDate) {
var today = new Date();
today.setHours(0,0,0,0);
return (selectedDate < today); // return true to disable