Skip to content

Instantly share code, notes, and snippets.

zackpyle / scroll-down-button.js
Created March 28, 2023 13:45
A Button that scrolls the page down from section to section smoothly
View scroll-down-button.js
// A Button that scrolls the page down from section to section smoothly
// Button needs to be positioned absolutely and design using css or a builder
// Here is the demo of this button in use
// Borrowed from and converted to jQuery
jQuery(document).ready(function($) {
const $button = $('.carret-down');
const $sections = $('.custom-section');
function* goToNextSection(event) {
zackpyle / equal-heights-by-row.js
Last active March 22, 2023 16:05
Set separate equal heights for each row of content on the page. This eliminates large gaps in content further down caused by a single tall item but keeps the items in the row equal with each other.
View equal-heights-by-row.js
// Equal Heights by row
$.fn.equalHeights = function() {
var max_height = 0;
$(this).each(function() {
max_height = Math.max($(this).height(), max_height);
$(this).each(function() {
zackpyle / posts-by-category.html
Last active March 20, 2023 16:07
Output posts separated by category using Loops & Logic plugin - Example using a Team and Team Category
View posts-by-category.html
<!-- Team CPT (team_member), and Team Category (team_category) - Separeted into their categories -->
<!-- Note: In this case, the order of the taxonomy matters, so we will use a plugin to set
menu order of team_category and use orderby=menu_order to respect that order instead of just outputting it in alpha order -->
<Loop type=taxonomy_term taxonomy=team_category orderby=menu_order>
<h2><Field title /></h2>
<Loop type=team_member taxonomy=team_category terms="{Field id}">
<Field title />
zackpyle / _Dynamic dropdown + content pulled from
Last active March 21, 2023 08:57
Dynamic content using a <select> dropdown on the frontend, and pulls content from a CPT. Output content using L&L
View _Dynamic dropdown + content pulled from

Pull posts from a CPT into a <select> field and then display content from that post based on if it is selected

- This example is showing a list of insurance companies and which states they cover

  1. The content is pulled from a CPT called insurance_company. That CPT has a taxonomy called state. Using Loops & Logic, we will output a <select> containing the insurance companies.
  2. Next to that, we will output a list of divs, one for each insurance company with their corresponding covered States.
  3. Then with the JS, we will hide all those divs, leaving an instructional div showing when nothing is selected. When an insurance company is selected, we will find the matching div and display it.
zackpyle / Add-Page-Slug-to-Body-Class.php
Created February 25, 2023 18:52
Page Slug Body Class
View Add-Page-Slug-to-Body-Class.php
<?php // ignore - for gist formatting only
// Add Page Slug to Body Class
function add_slug_body_class( $classes ) {
global $post;
if ( isset( $post ) ) {
$classes[] = $post->post_type . '-' . $post->post_name;
return $classes;
zackpyle / beaver-map-module-zoom.php
Created February 17, 2023 16:48
Set zoom level on Beaver Builder Map module
View beaver-map-module-zoom.php
<?php // ignore - for github formatting purposes
add_filter( 'fl_builder_map_args', function( $args, $settings ) {
$args['zoom'] = 18;
return $args;
}, 10, 2 );
zackpyle / remove-custom-taxonomy-metaboxes.php
Created February 9, 2023 17:40
Remove All Custom Taxonomy Sidebar Metaboxes
View remove-custom-taxonomy-metaboxes.php
<?php // ignore - for formatting only
// Useful if you are creating custom taxonomines and controlling them with ACF. This will remove all the metaboxes for your custom taxonomies
function edit_taxonomy_args( $args, $tax_slug, $cptui_tax_args ) {
// Set to false for all taxonomies created with CPTUI.
$args['meta_box_cb'] = false;
return $args;
add_filter( 'cptui_pre_register_taxonomy', 'edit_taxonomy_args', 10, 3 );
zackpyle / default-image-acf.php
Last active February 13, 2023 14:17
Add default image setting to ACF image fields
View default-image-acf.php
<?php //ignore this line - for formatting only
// add default image setting to acf image field
add_action('acf/render_field_settings/type=image', 'add_default_value_to_image_field');
function add_default_value_to_image_field($field) {
acf_render_field_setting( $field, array(
'label' => 'Default Image',
'instructions' => 'Appears when creating a new post',
'type' => 'image',
'name' => 'default_value',
zackpyle / Register-truncated-ACF-shortcode.php
Last active February 17, 2023 15:31
Shortcode to output an ACF field with user defined truncation length
View Register-truncated-ACF-shortcode.php
<?php //ignore this line - only for formatting
// Register the truncated ACF shortcode
add_shortcode('truncated_acf_field', 'truncated_acf_field_shortcode');
function truncated_acf_field_shortcode($atts) {
// Check if ACF is installed and activated
if( function_exists('get_field') ) {
zackpyle / _Read More Button - Expand section on
Last active November 30, 2022 15:14
Read More Button - Expand section on click
View _Read More Button - Expand section on

A Read More button (in Beaver Builder but could be adapted for anywhere)

- I have included html, css, and js examples -

I have added a bunch of comments to help you adapt to your situation and explain it along the way