• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

WP Bitz

A curated collection of code snippets for WordPress

  • Home
  • About
  • Blog
  • Code Snippets
You are here: Home / Archives for Code Snippets

Find duplicates values in a MySQL table

April 5, 2020

SELECT col, COUNT(col) FROM table_name GROUP BY col HAVING COUNT(col) > 1; …

Continue Reading

Delete orphaned post meta in WordPress database

April 5, 2020

DELETE pm FROM wp_postmeta pm LEFT JOIN wp_posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL …

Continue Reading

Simple plugin header

February 10, 2020

…

Continue Reading

Error log file by date with hash

February 2, 2020

// Get stored hashes. $error_log_hashes = get_option( 'error_log_hashes' ); // Get today's date. $date = date('Y-m-d'); // Check if …

Continue Reading

Error log files by date name

February 2, 2020

ini_set( 'error_log', WP_CONTENT_DIR . '/debug-' . date('Y-m-d') . '.log' ); …

Continue Reading

Run WordPress in debug mode without access to wp-config

January 9, 2020

add_action( 'template_redirect', 'my_enable_debug_mode' ); function my_enable_debug_mode() { // Turn on error reporting. …

Continue Reading

Compare versions in WordPress

December 17, 2019

/** * Use PHP's version_compare() to check the version * of WordPress (or a plugin or theme for that matter). * * Get currently …

Continue Reading

Enable error logging in wp-config.php

December 5, 2019

/** * The WP debug constants. * * These are used in wp-config.php to enable debugging. * * NOTE all of these MUST be inserted in …

Continue Reading

Error log utility function

December 5, 2019

/** * Writes string, array, and object data to the WP error log. * * To use, pass the result to write to the log as follows: * …

Continue Reading

  • « Go to Previous Page
  • Page 1
  • Interim pages omitted …
  • Page 4
  • Page 5
  • Page 6
  • Page 7
  • Go to Next Page »

Primary Sidebar

Join for free!

Get free code snippets, WordPress best practices, and practical Content Marketing advice from seasoned WordPress expert Chad Butler (butlerblog):

Recent Posts

  • Check and delete orphaned user meta in WordPress
  • Add a Database Connection to use WPDB
  • Notice: Function WP_Block_Patterns_Registry::register was called incorrectly
  • Use WP-CLI to back up your site
  • Bitnami WordPress Autoptimize cannot write to the cache directory

Copyright © 2026 · Maker Pro on Genesis Framework · WordPress · Log in