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.

Pre Get Posts

Set up query parameters for different CPT archives.
WP Query | Type: PHP

Proportional scaling of a container

There is more detail at the reference link for complex containers. .parent { height: 0; padding-bottom: 56.25%; /* 16:9 */ position: relative; } .child { position: [...]
CSS | Type: CSS

Pseudo Classes

Some very handy classes and selectors to know.
CSS | Type: CSS

Pure CSS triangle

Creates a triangle shape with nothing but CSS. Note that the border placement and color dictates triangle color and direction of pointer (opposite the visible border).
CSS | Type: CSS

Random order with ACF Repeater field

Repeatable fields can be stored in an array using PHP, and using the PHP shuffle() function, we can shuffle the array elements.
ACF, PHP | Type: PHP

RankMath Functions

Move RankMath metabox to bottom of the edit screen //change the metabox display location to bottom function rank_math_change_metabox_priority() { return 'low'; } add_filter( 'rank_math/metabox/priority', 'rank_math_change_metabox_priority' ); [...]
PHP, WP/CP | Type: PHP