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.
Multiple Templates for Custom Post Type»
Number of possible solutions; have not tested any of them yet. Maybe trying to make this too complicated: what about serving different template parts based on user type? Added Multiple…
CPT, WP/CP | Type: PHP
Namespace; if function exists»
WP-PageNavi CPT LISTING <?php if(function_exists('wp_pagenavi')) { wp_pagenavi(array('query' => $newslist )); //$newslist is name of query for 'news' cpt } else { echo 'Please enable WP-PageNavi!'; } ?> ALTERNATIVELY FOR BLOG…
PHP, WP/CP | Type: PHP
Nested Repeater»
How to display a repeater within a repeater (with conditionals).
ACF | Type: PHP
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 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