• 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

Get word count of a post

March 6, 2023

add_filter( 'the_content', function( $content ) { $words = explode( ' ', $content ); $word_count = count( $words ); …

Continue Reading

Restore Bitnami WordPress Filesystem Permissions

December 15, 2022

sudo chown -R bitnami:daemon TARGET sudo find TARGET -type d -exec chmod 775 {} \; sudo find TARGET -type f -exec chmod 664 {} \; sudo …

Continue Reading

Batch file to remove WordPress site in XAMPP

November 8, 2022

:: PHP, WP-CLI, and MYSQL all need to be path environment variables. :: If you get errors that indicate something is not recognized as an …

Continue Reading

Batch file to create WP site in XAMPP

November 8, 2022

:: This is for spinning up installs for dev work, so don't consider this for :: production applications. It creates everything off a …

Continue Reading

Add the Customizer to the Toolbar

October 28, 2022

add_action( 'admin_bar_menu', function( $wp_adminbar ) { global $wp; $current_url = home_url( add_query_arg( array(), $wp->request ) …

Continue Reading

Validate user registration email with Proofy.io API

October 24, 2022

/** * Validates email in native WP registration using Proofy.io API. * * @param array $errors A WP_Error object …

Continue Reading

Initialize Proofy.io API for email validation

October 24, 2022

add_action( 'init', function() { // Your user ID from Proofy $aid = 12345; // Your API key from Proofy $api_key = …

Continue Reading

Add a custom default avatar to WordPress

February 3, 2022

/** * This can be used to apply a custom default avatar to your WordPress * install. Change the $custom_avatar value below to the …

Continue Reading

Get post slug from post ID

January 6, 2022

$post_id = 7; $slug = get_post_field( 'post_name', $post_id ); …

Continue Reading

  • Go to page 1
  • Go to page 2
  • Go to page 3
  • Interim pages omitted …
  • Go to page 6
  • 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

  • Bitnami WordPress Autoptimize cannot write to the cache directory
  • Create and delete WordPress sites in XAMPP with a batch file
  • How to fix “Error: MySQL Shutdown Unexpectedly” in XAMPP control panel
  • Fix missing Customizer in WordPress 6
  • Use Proofy.io API to validate WordPress registrations

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