Skip to content

Instantly share code, notes, and snippets.

View itsHall's full-sized avatar
💭
Living

Tyler Hall itsHall

💭
Living
View GitHub Profile
@itsHall
itsHall / functions.php
Last active October 7, 2021 14:01
Disable RSS Feed and Show Message
<?php
function itsme_disable_feed() {
wp_die( __( 'No feed available, please visit the <a href="'. esc_url( home_url( '/' ) ) .'">homepage</a>!' ) );
}
add_action('do_feed', 'itsme_disable_feed', 1);
add_action('do_feed_rdf', 'itsme_disable_feed', 1);
add_action('do_feed_rss', 'itsme_disable_feed', 1);
add_action('do_feed_rss2', 'itsme_disable_feed', 1);
add_action('do_feed_atom', 'itsme_disable_feed', 1);
@itsHall
itsHall / functions.php
Last active October 7, 2021 14:01
Remove Gutenberg Block Library CSS from loading on the frontend
<?php
function mpc_remove_wp_block_library_css(){
wp_dequeue_style( 'wp-block-library' );
wp_dequeue_style( 'wp-block-library-theme' );
wp_dequeue_style( 'wc-block-style' ); // Remove WooCommerce block CSS
}
add_action( 'wp_enqueue_scripts', 'mpc_remove_wp_block_library_css', 100 );
@itsHall
itsHall / functions.php
Last active October 7, 2021 14:01
Change Search Path | WP
<?php
// Changes /s/ search path to /search/
function wpb_change_search_url() {
if ( is_search() && ! empty( $_GET['s'] ) ) {
wp_redirect( home_url( "/search/" . urlencode( get_query_var( 's' ) ) ) );
exit();
}
}
add_action( 'template_redirect', 'wpb_change_search_url' );
@itsHall
itsHall / scripts.js
Last active October 14, 2021 20:51
Functions to handle localstorage object with expiration
function setWithExpiry(key, value, ttl) {
const now = new Date()
const item = {
value: value,
expiry: now.getTime() + ttl
}
localStorage.setItem(key, JSON.stringify(item))
}