Skip to content

Instantly share code, notes, and snippets.

View wplit's full-sized avatar
💭
I may be slow to respond.

David Browne wplit

💭
I may be slow to respond.
View GitHub Profile
@wplit
wplit / footer-scripts.html
Created March 6, 2024 23:30
autofocus on link inside slide when becomes active
@wplit
wplit / .js
Last active March 6, 2024 02:47
scrollup after ajax end
document.addEventListener("bricks/ajax/end", () => {
window.scroll({
top: 0,
behavior: 'smooth'
});
})
@wplit
wplit / code-block.php
Created March 5, 2024 22:53
output just images from acf photo gallery field, with 'cell' class on images
<?php
global $post;
//Get the images ids from the post_metadata
$images = acf_photo_gallery('photo_gallery', $post->ID);
//Check if return array has anything in it
if( count($images) ):
//Cool, we got some data so now let's loop over it
foreach($images as $image):
@wplit
wplit / snippet.php
Last active March 5, 2024 11:46
reverse order of WP's adjacent for posts
<?php
add_action( 'get_previous_post_where', 'my_prev_post_where', 20 );
function my_prev_post_where( $sql ){
if ( !is_main_query() || !is_singular('post') ) {
return $sql;
}
return str_replace('<', '>', $sql);
@wplit
wplit / footer-scripts.html
Last active March 3, 2024 23:47
when slide becomes active, click read more link if not expanded inside slide.
@wplit
wplit / footer-scripts.html
Created February 20, 2024 10:16
listen for tabs toggle expanding, scroll to that tab toggle when it does.
@wplit
wplit / footer-scripts.html
Last active February 19, 2024 03:26
refresh current visible table when tab opened (add to page settings > custom code > footer scripts)
@wplit
wplit / copy-code.json
Created February 14, 2024 08:07
alternating layout for horizontal timeline
{"content":[{"id":"cbqhpm","name":"section","parent":0,"children":["uoccov"],"settings":{}},{"id":"uoccov","name":"container","parent":"cbqhpm","children":["jhrajz"],"settings":{"taxonomies":["category","post_tag"],"extrasCustomQueryCode":"<style>\nh1.my-heading {\n color: crimson;\n}\n</style>\n\n<h1 class='my-heading'>Just some custom HTML</h1>","_alignItems":"center","_gridTemplateColumns":"1fr 1fr 1fr"}},{"id":"jhrajz","name":"xproslider","parent":"uoccov","children":["tovupw"],"settings":{"slideAlignHorizontal":"center","slideAlignVertical":"center","arrows":"true","prevArrow":{"library":"fontawesomeSolid","icon":"fas fa-angle-left"},"nextArrow":{"library":"fontawesomeSolid","icon":"fas fa-angle-right"},"perPage":"6","gap":"20","conditionaljustifyContent":"center","perPage:tablet_portrait":"2","perPage:mobile_landscape":"1","_cssCustom":"/* change item to CSS grid */\n#brxe-jhrajz .brxe-xcontenttimeline .x-content-timeline_list[data-x-horizontal=\"true\"] .x-content-timeline_item {\n display: grid;\n
@wplit
wplit / code.php
Last active February 7, 2024 23:32
<?php
function maybePostLink( $field ) {
$loopObject = \Bricks\Query::get_loop_object();
if ( ! is_array( $loopObject ) ) return false;
$post_id = $loopObject[$field] ?? ''; // actual field