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.
Disable Gutenberg for selected Custom Post Types»
function my_disable_gutenberg( $current_status, $post_type ) { // Disabled post types $disabled_post_types = array( 'book', 'movie' ); // Change $can_edit to false for any post types in the disabled post types…
CPT, PHP, WP/CP | Type: PHP
Disable WordPress Default Image Link»
Disable annoying default image link in theme functions file. You can still make a link, but it won't be the default.
Custom Admin, Users | Type: PHP
Disable XML-RPC»
In the functions file: add_filter('xmlrpc_enabled', '__return_false');
Security | Type: PHP
Disallow File Edit»
Disable theme and plugin editor in admin.
Custom Admin, Users, wp-config | Type: PHP
Disallow Indexing of PDFs in Media»
Important if PDFs are only available behind login or downloadable after transaction.
¡Important!, eCommerce, WP/CP | Type: Other
Display Dates if Start and End Dates Same Month»
Handy snippet for displaying event dates when events can stretch over multiple days.
ACF, PHP | Type: PHP
Display Debugging status on Admin Bar»
Code shared by CodePotent; goes in your theme functions file. function codepotent_debug_notifier_register_admin_bar() { if (!current_user_can('manage_options')) { return; } global $wp_admin_bar; $label = esc_html__(' Debugging DISABLED ', 'codepotent-debug-notifier'); if (defined('WP_DEBUG')) { if (WP_DEBUG…
WP/CP | Type: PHP
Display Featured Image on Listing»
How to add featured image to other post types. ADD TO THEME FUNCTIONS // This theme uses post thumbnails add_theme_support( 'post-thumbnails', array( 'plans','listings','news','post' ) ); ON POST-TYPE SPEC 'supports' =>…
Images, PHP, WP/CP | Type: PHP
Display the Title for the Posts / Blog Page»
You can’t use the standard the_title(); template tag for the page name of the page that displays the blog listing (index.php); that tag will display the latest blog post title…
PHP, Template Tags, WP/CP | Type: PHP
Divs Same Height»
Make divs in a container equal heights.
Javascript, jQuery | Type: Javascript