Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
I may be slow to respond.

David Browne wplit

💭
I may be slow to respond.
View GitHub Profile
View gist:d69281d3a14aa21df89486691d5197e3
<?php
/*
* Paginatation on Advanced Custom Fields Repeater
*/
if( get_query_var('page') ) {
$page = get_query_var( 'page' );
} else {
@wplit
wplit / code-block.js
Last active Aug 5, 2020
scroll with id and offset (and fix for comment reply links not working)
View code-block.js
jQuery(document).ready(function($) {
const offset = 0, // change offset (px)
scrollTime = 300; // change scrolling animation time (ms)
$('a[href*="#"]').not('[href="#"]').not('[href="#0"]').not('[href*="replytocom"]').click(function (t) {
if (location.pathname.replace(/^\//, "") == this.pathname.replace(/^\//, "") && location.hostname == this.hostname) {
var e = $(this.hash);
(e = e.length ? e : $("[name=" + this.hash.slice(1) + "]")).length && (t.preventDefault(), $("html, body").animate({ scrollTop: e.offset().top - offset }, scrollTime));
}
View gist:fd970fe5c76c2001df60b2f51108884b
eyJzb3VyY2UiOiJodHRwOi8vZXh0cmFzIiwiY29tcG9uZW50IjpbeyJpZCI6ODMzLCJuYW1lIjoib3h5X2hlYWRlciIsIm9wdGlvbnMiOnsiY3RfaWQiOjgzMywiY3RfcGFyZW50IjowLCJzZWxlY3RvciI6Il9oZWFkZXItODMzLTYiLCJvcmlnaW5hbCI6eyJzdGlja3ktbWVkaWEiOiJwYWdlLXdpZHRoIiwic3RpY2t5X3Njcm9sbF9kaXN0YW5jZSI6IjAiLCJnbG9iYWxDb25kaXRpb25zUmVzdWx0Ijp0cnVlLCJzdGlja3lfaGVhZGVyIjoibm8iLCJzdGlja3ktYmFja2dyb3VuZC1jb2xvciI6IiNmZmZmZmYiLCJzdGlja3ktYm94LXNoYWRvdyI6Im5vbmUiLCJzdGlja3lfaGVhZGVyX2ZhZGVfaW4iOiJ5ZXMiLCJzdGlja3lfemluZGV4IjoiOTkiLCJjdXN0b20tanMiOiIiLCJnbG9iYWxjb25kaXRpb25zIjpbXSwiYXR0cl81ZWYxZDEyNTE4N2I2IjoiaHR0cHM6Ly9zY2hlbWEub3JnL1dQSGVhZGVyIiwiYXR0cl81ZWYxZDE4NzU0YjY4IjoiaXRlbXNjb3BlIiwib3ZlcmxheS1oZWFkZXItYWJvdmUiOiJuZXZlciJ9LCJhY3RpdmVzZWxlY3RvciI6Im1pbl9oZWFkZXJfMSIsIm5pY2VuYW1lIjoiSGVhZGVyIEJ1aWxkZXIgMSIsImNsYXNzZXMiOlsibWluX2hlYWRlcl8xIl0sImN0X2NhdGVnb3J5IjoiSGVhZGVycyJ9LCJjaGlsZHJlbiI6W3siaWQiOjgzNCwibmFtZSI6Im94eV9oZWFkZXJfcm93Iiwib3B0aW9ucyI6eyJjdF9pZCI6ODM0LCJjdF9wYXJlbnQiOjgzMywic2VsZWN0b3IiOiJfaGVhZGVyX3Jvdy04MzQtNiIsIm9yaWdpbmFsIjp7Imdsb2Jh
@wplit
wplit / inside repeater code block
Last active Jun 10, 2020
am I an even post or an odd post?
View inside repeater code block
<?php
global $counter;
if (0 == $counter % 2) {
// do something if an odd post
echo 'an odd post';
} else {
View gist:98a2c685a6b21eb99a8d00e7b8926668
jQuery('body').removeClass('off-canvas-toggled'); // remove the overflow hidden
jQuery('.oxy-off-canvas').removeClass('oxy-off-canvas-toggled'); // close the offcanvas
jQuery(jQuery('.offcanvas-inner').data('trigger-selector')).find('.hamburger').removeClass('is-active'); // if the trigger is burger, close it
@wplit
wplit / code block
Created Jun 6, 2020
make sure offcanvas closes when menu item clicked if hashlink
View code block
jQuery('.oxy-off-canvas .menu-item a[href*=\\#]').on('click', function (event) {
if(this.pathname === window.location.pathname){
jQuery('body').removeClass('off-canvas-toggled');
jQuery('.oxy-off-canvas').removeClass('oxy-off-canvas-toggled');
jQuery(jQuery('.offcanvas-inner').data('trigger-selector')).find('.hamburger').removeClass('is-active');
}
});
@wplit
wplit / code blok
Created Jun 5, 2020
remove current post
View code blok
<?php
add_action('pre_get_posts','remove_current_post');
function remove_current_post($query) {
$current_post = get_the_ID();
$query->set('post__not_in', array($current_post));
}
?>
@wplit
wplit / sda
Created May 26, 2020
seopress
View sda
function sp_titles_template_variables_array($array) {
$array[] = '%%oxygen%%';
return $array;
}
add_filter('seopress_titles_template_variables_array', 'sp_titles_template_variables_array');
function sp_titles_template_replace_array($array) {
if (class_exists('OxygenElement')) {
$array[] = substr(strip_tags(wp_filter_nohtml_kses(do_shortcode(get_post_meta(get_the_ID(), 'ct_builder_shortcodes', true), true))), 0, 160);
}
@wplit
wplit / js
Created May 15, 2020
test.js
View js
jQuery(document).ready(function($){
console.log('document');
});
jQuery(window).load(function($){
console.log('window');
});
(function ($) {
console.log('none');
@wplit
wplit / style.css
Created May 12, 2020
single image flip css
View style.css
.single-product .woocommerce div.product div.images .woocommerce-product-gallery__wrapper {
position: relative;
}
.single-product .secondary-image {
position: absolute;
top: 0;
left: 0;
right: 0;
opacity: 0;
You can’t perform that action at this time.