A collection of (mostly) WordPress-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.
Paging CPT Listing on Static Home Page»
Paging a query on static page set as home page (clicks to /page/2 but continues to show original items)
WP Query | Type: PHP
Patch count(): countable in wp-includes/post-template.php on line 284»
Normally a bad idea to patch a WP core file, but here’s the patch: // original code: if ( $page > count( $pages ) ) //add BEFORE above code: if…
PHP, WP/CP | Type: PHP
PHP 7.2 Countable issue»
Before PHP 7.2 when passing a non-array to count(), it returned 1. With 7.2, count() emits a warning when you give it a non-array.
PHP | Type: PHP
PHP Date/Time Guide»
Useful php date/time formulas.
¡Important!, PHP | Type: PHP
Pre Get Posts»
Set up query parameters for different CPT archives.
WP Query | Type: PHP
Prepopulate Gravity Forms with Registered User Info»
Pre-populate form fields with info from user profile for registered, logged in users.
Forms | Type: Other
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: absolute; top: 0; left:…
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
Query Posts with ACF Values (Basic)»
Displaying posts that include a particular value for an ACF field (meta_key).
ACF | Type: PHP