Skip to content

Instantly share code, notes, and snippets.

@zackpyle
zackpyle / acf-repeater-hide-show-jquery.js
Last active May 18, 2023 14:45
ACF Repeater + Hide/Show jQuery #acf #beaverbuilder
jQuery(document).ready(function($) {
// Hide all expanded steps
$('.expandedstep').hide()
//Show expanded steps while in the builder
$('html.fl-builder-edit .expandedstep').show();
// When an expand step button is clicked
$('.expandstepbtn').on('click', function(e) {
@zackpyle
zackpyle / acf-google-address-shortcode.php
Last active May 18, 2023 14:44
ACF Google Address Field Shortcode #acf
<?php
// ACF Google Map Field -> Address Shortcode
add_shortcode( 'acf_address' , function( $atts ) {
if (!function_exists('get_field') ) return '';
$atts = shortcode_atts( array( 'field' => false , 'sub' => 'address' ) , $atts, $shortcode = 'acf_address' );
if ($atts[ 'field' ] && $map = get_field( $atts[ 'field'] ) ) {
if ( isset( $map[ $atts['sub'] ] ) ) return $map[ $atts['sub'] ];
}
return '[ something went wrong ]';
@zackpyle
zackpyle / acf-numbers-with-commas.php
Last active February 23, 2024 03:40
Format ACF Number fields with Commas on the Frontend #acf
<?php
// Return ACF Number Fields Formatted with Commas on the Frontend
add_filter('acf/format_value/name=ACF_FIELD_NAME', 'acf_number_comma', 20, 3);
add_filter('acf/format_value/name=ANOTHER_ACF_FIELD_NAME', 'acf_number_comma_decimal', 20, 3);
// Without Decimal
function acf_number_comma($value, $post_id, $field) {
$value = number_format(floatval($value));
return $value;
@zackpyle
zackpyle / beaver-builder-noloop-vimeo-jQuery.js
Last active May 18, 2023 14:42
Turn Off Looping of Beaver Builder Background Vimeo Video #beaverbuilder
jQuery(document).ready(function($) {
let $vimeoPlayer = $('#hero-row .fl-bg-video').data('VMPlayer');
$vimeoPlayer.setLoop(false);
});
@zackpyle
zackpyle / makes-bb-column-clickable.js
Last active December 19, 2023 16:00
Makes a Beaver Builder Column Clickable #beaverbuilder
/**
* Makes a BB Column clickable.
* Pre-requisite: There must be an A Tag contained within the column element and a class of clickable-col for the column
*/
jQuery(document).ready(function($) {
// Exit if BB layout is in edit mode.
if (typeof window.FLBuilderConfig !== 'undefined') {
return;
}
@zackpyle
zackpyle / remove-custom-taxonomy-metabox.php
Last active May 18, 2023 14:42
Remove Custom Taxonomy Metabox from WP Sidebar #wordpress #cptui
<?php
// example custom post type is "event"
// example custom taxonomy is "events-category"
function remove_default_event_category_metabox() {
remove_meta_box( 'tagsdiv-events-category', 'event', 'side' );
}
add_action( 'admin_menu' , 'remove_default_event_category_metabox' );
@zackpyle
zackpyle / scrolled-header-code.js
Last active May 18, 2023 14:41
Swap Headers on Scroll in Beaver Builder/Beaver Themer #beaverbuilder #beaverthemer
/* JS for scrolled header: */
const header_a = document.querySelector('#header-row-a');
const header_b = document.querySelector('#header-row-b');
var posY = 0;
window.addEventListener('scroll', function(e) {
//how far down you scroll
if (this.pageYOffset > 855) {
if (this.pageYOffset > posY) {
@zackpyle
zackpyle / equal-height-modules.js
Last active May 17, 2023 18:13
Set equal heights using jQuery
jQuery(document).ready(function($) {
$.fn.equalHeights = function() {
let max_height = 0;
$(this).each(function() {
max_height = Math.max($(this).height(), max_height);
});
$(this).each(function() {
$(this).height(max_height);
});
};
@zackpyle
zackpyle / *ACF Snippets.md
Last active May 19, 2023 14:31
Collection of useful ACF snippets #acf

Collection of useful ACF Snippets

  1. Add Field to Body Class
  2. Custom Excerpt Field
  3. Default Image
  4. Google Address Shortcode
  5. Google Map Multiple Marker Shortcode
  6. Numbers with commas
  7. Repeater + Bootstrap Modal + Modal Nav
  8. Repeater with button for Show-Hide
@zackpyle
zackpyle / *Best Snippets*
Last active May 1, 2024 20:05
Best PHP/JS Snippets
This is a collection of my most used or most useful PHP and JS snippets
**Disclaimer, I didn't write most of these - I just curated them over the years**