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 attributes to WordPress Nav Menu Links (a tag)
This can be very useful if you need to add attributes for a menu script. /** * Add custom attribute and value to a nav menu [...]
Nav Menu, WP/CP | Type: PHP
Add Columns to Admin CPT Listing
See David Lord site for implementation.
ACF, CPT, Custom Admin | Type: PHP
Add Contextual Help for Custom Post Types
The contextual help feature is a descending tab which can be seen in the top right of pages where available.
Custom Admin, Users, WP/CP | Type: PHP
Add current class to post type navigation menu
The examples show posts (where the homepage is the blog list), but this works for any custom post type as well. I’ve used it forever; don’t [...]
CSS, Nav Menu, PHP | Type: PHP
Add EDD Cart Info Anywhere
Allows you to add cart info in header, sidebar, etc.
eCommerce | Type: Other
Add Message on Thumbnail Metabox
Sometimes you need to change the message.
Custom Admin, Users, WP/CP | Type: PHP
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






