Skip to content

Instantly share code, notes, and snippets.

View taricco's full-sized avatar

Tim in Seattle taricco

  • Seattle, WA
View GitHub Profile
//Add to stylesheet
.site-header {
position: sticky !important;
top: 0;
background-color: var(--light-1);
z-index: 10;
transition: background-color 0.3s ease;
} /* Sticky navigation styling */
.site-header.sticky {
background-color: var(--light-2);
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-XXXX');</script>
<!-- End Google Tag Manager -->
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-XXXX"
/*** Custom template tag for styling an ACF date/time field (IMPORTANT, this works for the ACF Date/Time field only)
Set ACF date/time field return format to: Ymd H:i:s
Tag format: {{datetimeformat.event_start|M j, Y | g:i a}}
–––––––––––––––––––––––––––––––––––––––––––––––––– ***/
add_filter("render_block", "wsv_date_time_format_tags", 11, 2);
function wsv_date_time_format_tags($block_content, $block) {
// Updated pattern to match {{datetimeformat.<field>|<format>}} and allow the | character in the format
$pattern = "/{{datetimeformat\.([\w-]+)\|([,\w\s:-\|]+)}}/";
<script type="text/javascript">
// Function to replace the SVG in all matching buttons
function replaceSVGIcons(buttonSelector, newSVGCode) {
// Select all buttons containing the old SVG
const buttons = document.querySelectorAll(buttonSelector);
// Loop through each button and replace the SVG
buttons.forEach(function(button) {
const oldSVG = button.querySelector('svg');
if (oldSVG) {
//Control the scroll speed in GeneratePress
add_filter( 'generate_smooth_scroll_duration', 'wsv_smooth_scroll_duration' );
function wsv_smooth_scroll_duration() {
return 1600; // milliseconds
}
//Add smooth-scroll automatically to all hash/achor links in GeneratePress
add_filter('generate_smooth_scroll_elements', 'wsv_smooth_scroll', 10, 1);
function wsv_smooth_scroll($elements){
$elements[] = 'a[href*="#"]';
/***
1 - Replace cpt-name with the CPT name (uses a dash if CPT uses a dash)
2 - Replace cpt_name (CPT name, but with an underscore)
–––––––––––––––––––––––––––––––––––––––––––––––––– ***/
/* Insert "cpt-name" CPT content as a shortcode.
[cpt_name_shortcode id="POST_ID"] */
function wsv_cpt_name_shortcode($atts) {
$atts = shortcode_atts(array(
'id' => '', // Default value if 'id' attribute is not provided
# ----------------------------------------------------
# | HTACCESS for WordPress on NameHero |
# | Version: 09/27/24 non-WWW |
# ----------------------------------------------------
# BEGIN Force SSL
<IfModule mod_rewrite.c>
RewriteEngine On
# Check if HTTPS is off and redirect to HTTPS version of the site
RewriteCond %{HTTPS} !=on
<?php
define( 'DISALLOW_FILE_EDIT', true ); // Disable File Editor
/**
* The base configuration for WordPress
*
* The wp-config.php creation script uses this file during the
* installation. You don't have to use the web site, you can
* copy this file to "wp-config.php" and fill in the values.
*
* This file contains the following configurations:
//Exclude Custom Post Types from WordPress search
function wsv_exclude_cpt_from_search( $query ) {
if ( ! is_admin() && $query->is_main_query() && $query->is_search() ) {
// Exclude both 'pp_video_block' and 'sponsors-cpt' from search results
$excluded_post_types = array( 'pp_video_block', 'sponsors-cpt', 'page-archive', 'impact-update-cpt', 'lp' );
$post_types = $query->get( 'post_type' );
// If $post_types is empty or set to 'any', exclude the specified post types
if ( empty( $post_types ) || 'any' === $post_types ) {
$post_types = get_post_types( array( 'exclude_from_search' => false ) );
function wsv_cpt_name_order_backend($wp_query) {
if (is_admin() && $wp_query->is_main_query()) {
// Get the post type from the query
$post_type = $wp_query->get('post_type');
// Check if the post type is 'events'
if ($post_type == 'cpt-name') {
$wp_query->set('orderby', 'title');
$wp_query->set('order', 'ASC');
}