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 better snippets or references.
Clear Input Field on Focus
Not sure why you wouldn't use a placeholder instead.
Forms | Type: Javascript
Clearfix
Maybe the most widely used clear after float.
CSS | Type: CSS
Common WP functions converted to variables
Sometimes functions are easier to use in conditional statements if converted to variables.
ACF, PHP, WP/CP | Type: PHP
Compression – wp-config
Enable compression in wp-config /* Compression */ define( 'COMPRESS_CSS', true ); define( 'COMPRESS_SCRIPTS', true ); define( 'ENFORCE_GZIP', true );
wp-config | Type: PHP
Conditional Based on Field Value
Conditional based on values for single-value fields (radio buttons, select, etc).
ACF, PHP | Type: PHP
Conflicting Scripts
This constant is enabled by default and means that all JavaScript files are loaded with a single call, rather than multiple calls to multiple files (faster [...]
Troubleshooting | Type: Javascript
Connect to Separate Database
The wpdb object can be used to access any database and query any table. Absolutely no need to be WordPress related, which is very interesting. The [...]
DB Query, WP/CP | Type: PHP
COVID-19 Embed JS
<div class="covid-act-now-embed" /><script src="https://covidactnow.org/scripts/embed.js"></script></div>
CPT to CPT Reverse Query
Reverse query from different post types associated via ACF relationship field.
ACF, CPT, WP Query | Type: PHP
Create sub posts for a WordPress custom post type
This has to do with creating hierarchical CPTs, so you can have ‘sub-posts’ as children of a CPT single.
CPT, WP/CP | Type: PHP