Skip to content

Instantly share code, notes, and snippets.

View timstl's full-sized avatar

Tim Gieseking timstl

View GitHub Profile
@timstl
timstl / wpseo_remove_home_breadcrumb.php
Last active July 14, 2023 10:00
Remove "Home" link from Yoast WordPress SEO's breadcrumbs. Add to functions.php.
function wpseo_remove_home_breadcrumb($links)
{
if ($links[0]['url'] == get_home_url()) { array_shift($links); }
return $links;
}
add_filter('wpseo_breadcrumb_links', 'tg_remove_home_breadcrumb');
@timstl
timstl / relatedposts.php
Last active April 1, 2019 21:37
related posts
@timstl
timstl / excludefeatured.php
Last active March 29, 2019 20:49
Exclude featured posts from main WordPress blog loop
/**
* Exclude featured posts from main blog loop
*/
function bt_exclude_featured_from_blog_index( $query ) {
if ( ! is_admin() && $query->is_home() && $query->is_main_query() ) {
$post_ids = bt_featured_post_ids();
if ( ! empty( $post_ids ) ) {
$query->set( 'post__not_in', $post_ids );
}
}
@timstl
timstl / jquery.backtotop.js
Last active December 5, 2018 21:39
jquery.backtotop.js
/*
back to top
usage: $('#main').backtotop();
use localScroll plugin for smooth scrolling
style in CSS.
*/
;(function($) {
$.fn.backtotop = function(options) {
@timstl
timstl / jquery.scrollclass.js
Last active September 15, 2018 14:38
Toggle class based on scroll position. Add your effects and style changes to your CSS.
(function($) {
$.fn.scrollclass = function(options) {
var opts = $.extend({}, $.fn.scrollclass.defaults, options),
$this = this,
state2 = false;
$(document)
.scroll(function() {
if (state2 == false && $(this).scrollTop() > opts.pos) {
state2 = true;
@timstl
timstl / .gitignore
Last active September 6, 2018 14:09
WordPress .gitignore template; A compilation of many examples customized to fit our needs.
# ignore everything in the root except the "wp-content" directory.
/*
!wp-content/
# ignore everything in the "wp-content" directory, except:
# plugins and themes directories
wp-content/*
!wp-content/plugins/
!wp-content/themes/
wp-content/themes/twenty*
@timstl
timstl / scrollmagic.dataclasstoggle.js
Last active November 9, 2017 20:45
ScrollMagic: Toggle class with HTML data attribute.
// ScrollMagic
const controller = new ScrollMagic.Controller();
// Animate an object to a y or x value
// Usage: data-to-target="y:-100"
// Optional: data-to-target-mobile="y:-50" (requires SSM)
// Optional: data-duration="50%"
// Optional: data-trigger-element="#someDiv" (defaults to parent)
// Optional: Adjust animation offset using data-animation-offset="X"
$('[data-to-target]').each(function() {
@timstl
timstl / scrollmagic.datatotarget.js
Created November 9, 2017 20:33
ScrollMagic: Animate element using HTML data attribute
// ScrollMagic
const controller = new ScrollMagic.Controller();
// Animate an object to a y or x value
// Usage: data-to-target="y:-100"
// Optional: data-to-target-mobile="y:-50" (requires SSM)
// Optional: data-duration="50%"
// Optional: data-trigger-element="#someDiv" (defaults to parent)
$('[data-to-target]').each(function() {
const $this = $(this);
@timstl
timstl / the_field_srcset.php
Last active August 24, 2016 20:53
Function to convert ACF image field into image tag with srcset.
<?php
/*
Usage: the_field_srcset('field_name');
ACF field should return Image ID.
*/
function the_field_srcset($field, $before='', $after='', $size = 'full', $echo = true) {
if (get_field($field)) {
$img = wp_get_attachment_image(get_field($field), $size);
@timstl
timstl / jquery.colequalize.js
Last active August 17, 2016 15:45
jQuery plugin to equalize height of a set of elements if you can't do so via CSS for whatever reason.
/*
Column Equalize
Example: $('.col-equalize .col').colequalize();
*/
;(function($) {
$.fn.colequalize = function(options) {
var h = 0;