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 / style.css
Created December 28, 2019 02:06
Carousel/Slider from WordPress Gallery using Flickity (update CSS)
.gallery-carousel {
display: block;
margin-bottom: 1em;
}
.gallery-carousel:not(.columns-1) .blocks-gallery-item:last-child {
margin-right: 16px;
}
.gallery-carousel .blocks-gallery-item {
@wplit
wplit / code-block.js
Created December 28, 2019 02:10
Carousel/Slider from WordPress Gallery using Flickity (updated flickity-init.js)
(function ($) {
$('.gallery-carousel .blocks-gallery-grid').flickity({
// At the end of cells, wrap-around to the other end for infinite scrolling.
wrapAround: true,
// Align cells within the carousel element.
cellAlign: 'left',
@wplit
wplit / code-block.php
Created January 30, 2020 21:44
filter query for events that are in future
<?php
add_action( 'pre_get_posts', 'lit_event_date_filter' );
function lit_event_date_filter($query) {
$date_now = date('Ymd');
$query->set( 'meta_query', array(
array(
'key' => 'event_date',
@wplit
wplit / code-block.php
Last active January 30, 2020 21:46
close filter
<?php
remove_action( 'pre_get_posts', 'lit_event_date_filter' );
?>
@wplit
wplit / easy-posts.css
Last active February 3, 2020 23:36
three column easy posts
%%EPID%% .oxy-posts {
display: flex;
flex-direction: row;
flex-wrap: wrap;
}
%%EPID%% .oxy-post {
width: calc(100% / 3);
}
@wplit
wplit / easy-post-grid.css
Created February 3, 2020 23:42
three column easy posts with grid
%%EPID%% .oxy-posts {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
}
@media (max-width: 1120px) {
%%EPID%% .oxy-posts {
grid-template-columns: 1fr 1fr;
}
@wplit
wplit / code-block.php
Last active February 14, 2020 01:24
Filter products in repeater to include only those in the same brand, while not including current post
<?php
add_action( 'pre_get_posts', 'lit_brand_filter' );
function lit_brand_filter($query) { // Change lit_brand_filter to custom name, different each time you use
$taxonomy = 'brand'; // Change to taxonomy name
$terms = get_the_terms( get_the_ID(), $taxonomy );
$tax_query = array(
'taxonomy' => $taxonomy,
@wplit
wplit / code-block.php
Last active February 17, 2020 03:40
Exclude posts with specific taxonomy term
<?php // first code block
add_action( 'pre_get_posts', 'lit_taxonomy_term_filter' );
function lit_taxonomy_term_filter($query) {
$taxonomy = 'category'; // My Taxonomy
$terms = array('travel', 'food'); // My terms to exclude
$tax_query = array(
'taxonomy' => $taxonomy,
@wplit
wplit / shortcode.php
Created March 6, 2020 03:33
Post ID in repeaters
add_shortcode( 'repeater_post_id', 'lit_post_class_sc' );
/**
* Shortcode for adding post classes inside Oxygen Repeater
*/
function repeater_post_id( $atts, $content = null ) {
$post_id = get_the_id();
return '<div id="prefix-'. $post_id . '" />' . $content . '</div>';
@wplit
wplit / snippet.php
Created March 25, 2020 22:49
add to <head>
add_action('wp_head', 'your_function_name');
function your_function_name() {
echo '<meta name="robots" content="noindex">';
}