PHP Snippets

PHP Error Fix: Uncaught ValueError: Unknown format specifier “S”

Here's a problem that I've seen a few times of late, especially since the introduction of PHP version 8 and higher.   WordPress sites using outdated themes are often showing errors in and around the site especially in the Dashboard, the specific error being: PHP [...]

WordPress Shortcode to Get Text from URL Vars/Parameters

Sometimes you may have a URL that has parameters or variables included in it that you wish to display on a page or post within WordPress.  In cases like this all that's needed is a simple function to get the information from the URL onto [...]

WooCommerce: Select First Variation if it Exists

If your WooCommerce variations aren't user friendly for the user because it's always asking them to choose from a huge selection, or showing "Choose an option" or "Please select" text even if there's only one variation, a simple fix will help make your WordPress [...]

Critical Error on WordPress/Avada for PHP 7.2

Recently a client reached out concerning a critical error in WordPress using Avada when trying to access the wp-admin area of the website. It appears that the problem is due to an issue with Revolution Slider, specifically a metabox function that's including in the admin [...]

WordPress Resize at Upload Plugin mysql_real_escape_string() Error

If like me you use the WordPress plugin Resize at Upload, or Resize at Upload Plus, it's quite likely that you'll be getting a mysql error when changing the settings.  Something like: Access denied for user ''@'localhost' (using password: NO) in /home/accountname/public_html/wp-content/plugins/resize-at-upload/resize-upload.php on line 63 [...]

2018-11-07T01:08:52+00:00June 26th, 2016|PHP Snippets, WordPress Snippets|1 Comment

WordPress RSS Widget: Open Links in a New Window

I've recently come across a slight problem with one of my clients whereby they wanted the RSS feed widget to open all incoming links in a new window. And why wouldn't they? Especially if they're external RSS feeds that are being parsed. We could have [...]

2018-02-02T03:09:34+00:00June 4th, 2013|PHP Snippets, WordPress Snippets|1 Comment

Search and Replace in Web Files

This handy function will search and replace all instances of a search term in every file with the PHP extension, across all directories and subdirectories. Upload the file to your root directory and run it. function callbackDir($dir){ $searchString = "searchforthis"; $newValue = "replacewiththis"; // directory, [...]

2011-03-02T23:14:27+00:00June 9th, 2010|PHP Snippets|0 Comments

Remove Trackbacks and Pingbacks from Comments

Unfortunately, the default Recent Comments widget also includes trackbacks and pingbacks and the sight ain’t so lovely thus I had to add this hack to weed out the trackbacks and pingbacks. Open your theme's functions.php file and add the following code if ( !$comments = [...]

2011-03-02T23:20:07+00:00June 7th, 2010|PHP Snippets|2 Comments
Go to Top