Home
Welcome to WP Freelance, the best collection of WordPress code, guides and information to make awesome WordPress sites, especially for freelancers.
Latest posts
Disable xmlrpc.php and Secure your WordPress Website
xmlrpc.php is part of WordPress that is rarely used by any site, but poses a security risk. There has been a high level of attacks targeting this file so my advice it so secure your WordPress website by disabling this file completely. You can do so by adding this code to the bottom of your…
Continue Reading Disable xmlrpc.php and Secure your WordPress Website
Can’t connect to the clients FTP?
Here are some tips Check the transcript log of your FTP client. In the example below the server was telling me that I needed to be using SSL/TLS, which did solve the problem.
Convert text lines to list items
<?php // Get the points from the ACF field $points = get_sub_field(‘points’); // Add new line to each point $points = explode(“\n”, $points); // Now convert to HTML ?> <ul><?php foreach($points as $point) : ?> <li><?php echo $point ?></li><?php endforeach; ?> </ul>
WooCommerce Update Checklist
WooCommerce is a powerful but complex system, and larger installations often have some additional plugins or custmisations. After updating the WooCommerce plugin, or any other related plugins, it’s important to test your store to ensure everything works as expected and any bugs are identified and fixed. Here’s a handy list to help get your store…
Hide the annoying outline for mouse users but preserves it for keyboard users
CSS that get’s rid of the annoying outline for mouse users but preserves it for keyboard users, and is ignored by browsers that don’t support :focus-visible. :focus:not(:focus-visible) { outline: none } Source @LeaVerou
Continue Reading Hide the annoying outline for mouse users but preserves it for keyboard users
How to Disable WordPress PHP Error Messages
Sometimes even with the WP_DEBUG setting set to false you will see PHP error messages. This is normally because of the PHP setup configuration on the server. If you are seeing warnings that are causing issues with your theme add the code below to your wp-config.php file and all errors will be hidden. ini_set(‘display_errors’, ‘Off’);ini_set(‘error_reporting’,…
Continue Reading How to Disable WordPress PHP Error Messages
How to change menu items to sentence case in WordPress
// Update menu items to sentence case add_action(‘wp_loaded’, ‘fl_update_menu_items_case’); function fl_update_menu_items_case() { // Get all of the menu item posts $all_posts = get_posts([ ‘posts_per_page’ => -1, ‘post_type’ => ‘nav_menu_item’, ]); // Loop each one setting the title case foreach ( $all_posts as $single ) { wp_update_post([ ‘ID’ => $single->ID, ‘post_title’ => ucfirst( strtolower( $single->post_title )…
Continue Reading How to change menu items to sentence case in WordPress
Mailtrap not working on live WordPress server (Siteground) – Gateway Timeout error
If Mailtrap is not sending on your WordPress site and you are getting a Gateway Timeout error, try changing the Mailtrap SMTP port to 465. This worked for my Siteground hosted WordPress site. Ports 2525 and 25 would cause the Gateway Timeout error.
Continue Reading Mailtrap not working on live WordPress server (Siteground) – Gateway Timeout error
Add Cache Version Number to editor-style.css
You can add a custom style sheet to format the WordPress editor using add_editor_style. A frustrating problem with this technique is that browsers will typically cache this css file pretty hard, and so it’s tricky to see that changes you made appear in the editor. This is how you would typically add a custom style…
Continue Reading Add Cache Version Number to editor-style.css
Change Default Image Size on Visual Composer Single Image
The Visual Composer Single Image component defaults the Image Size to ‘thumbnail’. This really isn’t very useful, especially if your clients are using Visual Composer to build pages. An Image Size of ‘large’, ‘medium’, or even a custom image size, is much more useful. If you’ve set ‘large’ to be the same width as your main content…
Continue Reading Change Default Image Size on Visual Composer Single Image
Set src using just CSS
Sometimes we need to change the src of an <img> element, but we don’t have access to the HTML, like when styling a plugin. But, CSS is our friend here, and we can use the url pseudo element to set the <img> src. <style> .my-class { content:url(“http://imgur.com/SZ8Cm.jpg”); }</style><img class=”my-class”> Check out this JSFiddle. Should work in…
fatal: pathspec ‘vendor/entypo/Iconr’ did not match any files
If SourceTree gives you the error ‘fatal: pathspec ‘vendor/entypo/Iconr’ did not match any files’ you need to ignore the file or delete it.
Continue Reading fatal: pathspec ‘vendor/entypo/Iconr’ did not match any files
Show PHP error or debug log in VS Code terminal window
Monitoring your PHP error log is a great way of tracking any errors or debug information when working on your site. Showing the log file in the VS Code terminal window is a great way of keeping an eye on any log entries as they appear. The tail command can be used to show the…
Continue Reading Show PHP error or debug log in VS Code terminal window
DIY Honeypot to Stop Spam Registrations
Problem Here’s a really effective way to prevent registration form spam (and other forms) by using a simple honeypot. Note: If you’re using Contact Form 7, there is a great plugin for that. Problem Our online form is being filled out by a bot, and being submitted. Not only is WordPress filling up with fake…
Change Default Image Size on Visual Composer Single Image
The Visual Composer Single Image component defaults the Image Size to ‘thumbnail’. This really isn’t very useful, especially if your clients are using Visual Composer to build pages. An Image Size of ‘large’, ‘medium’, or even a custom image size, is much more useful. If you’ve set ‘large’ to be the same width as your main content…
Continue Reading Change Default Image Size on Visual Composer Single Image
WordPress redirect https to http without SSL certificate
If your website has an invalid SSL certificate for your site (perhaps your shared hosting company has a wildcard certificate), most browsers will show a warning about the validity of the certiticate. However, Google could still index your site using https: URLs, as it assumes you have a valid SSL certificate. The problem is, if people…
Continue Reading WordPress redirect https to http without SSL certificate
Assign a Tag to a Contact in Infusionsoft using Affiliates Pro
If you’re using Affiliates Pro, and Infusionsoft, you might want to tag the Infusionsoft contact for an affiliate, once they have signed up. Here’s a handy function to do that. Important: You need to installed the Infusionsoft SDK plugin first (or add the SDK to your theme yourself). // Affiliate added add_action( ‘affiliates_added_affiliate’, ‘my_affiliates_added_affiliate’ ); function my_affiliates_added_affiliate(…
Continue Reading Assign a Tag to a Contact in Infusionsoft using Affiliates Pro