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 / snippet.php
Last active April 11, 2020 23:24
add offset to post category
add_action( 'pre_get_posts', 'lit_offset_category_filter' );
function lit_offset_category_filter($query) {
if ( ! is_admin() && $query->is_main_query() ) { // Apply to main WP query
if( $query->is_category()) { // Only on category pages
$offset = '3'; // Number of posts to offset
$query->set( 'offset', $offset );
@wplit
wplit / code-block.php
Last active April 15, 2020 03:33
show taxonomy field inside single post template (must have only one term)
<?php
global $post;
$taxonomy = 'study_series';
$taxonomy_field = 'series_subtitle';
$terms = wp_get_post_terms($post->ID, $taxonomy, array('fields' => 'ids'));
if ($terms) {
@wplit
wplit / repeater.js
Created May 4, 2020 02:13
no posts in repeater
(function($) {
$('#%%ELEMENT_ID%%').children('.oxy-repeater-pages-wrap:only-child' ).text( "No Posts Foud" );
})( jQuery );
@wplit
wplit / snippet.php
Created May 6, 2020 08:36
resize woocommerce gallery thumbnails
add_filter( 'woocommerce_get_image_size_gallery_thumbnail', function( $size ) {
return array(
'width' => 200,
'height' => 200,
'crop' => 1,
);
} );
@wplit
wplit / code-snippets.php
Created May 12, 2020 06:06
single product image flip
// Remove zoom and slider from single product
add_action("after_setup_theme", "lit_remove_woo_theme_support");
function lit_remove_woo_theme_support() {
remove_theme_support( 'wc-product-gallery-zoom' );
remove_theme_support( 'wc-product-gallery-slider' );
}
// Remove product thumbnails
remove_action( 'woocommerce_product_thumbnails', 'woocommerce_show_product_thumbnails', 20 );
@wplit
wplit / style.css
Created May 12, 2020 06:06
single image flip 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;
@wplit
wplit / js
Created May 15, 2020 05:13
test.js
jQuery(document).ready(function($){
console.log('document');
});
jQuery(window).load(function($){
console.log('window');
});
(function ($) {
console.log('none');
@wplit
wplit / sda
Created May 26, 2020 10:29
seopress
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 / code blok
Created June 5, 2020 09:26
remove current post
<?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 / code block
Created June 6, 2020 12:02
make sure offcanvas closes when menu item clicked if hashlink
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');
}
});