Web Dev Snippets

A collection of (mostly) WordPress/ClassicPress-related snippets and references I’ve found useful and worth keeping where I can find them. Feel free to use what you like, and point me to some other snippets or references.

ACF Repeater Random Set

This example is for options, which would perhaps appear in the footer. $randomquotes = get_field('random_quotes', 'option'); $row_count = count($randomquotes); $i = rand(0, $row_count - 1); echo [...]
ACF | Type: PHP

Add a custom WP_Query to a Divi page

Recently, I designed a site using Divi because that’s what the client is used to. They didn’t have a lot of technical requirements, so I figured [...]

Add Persistent Text-Resize Button

Example shows ‘bigger’ class added to all paragraphs on a page, but CSS targets specific paragraph types. jQuery toggles the class and also makes the class [...]
Accessibility, CSS, Javascript, jQuery | Type: Javascript

Add search form to specific nav menu

add_filter('wp_nav_menu_items', 'add_search_form', 10, 2); function add_search_form($items, $args) {     if( $args->theme_location == 'MENU-NAME' )     $items .= '<ul>         <li class="search">         <form id="searchform" role="search" action="'.home_url( '/' ).'" method="get"><input id="s" [...]
Nav Menu, Search | Type: PHP