Wordpress | Rest API / lightroom / timeout / seo / optimize/ image process + more!


Fix: The WordPress REST API

The WordPress REST API is the best way to access or modify WordPress data asynchronously without slowing down your site or your admin. You can expect the whole WordPress admin to use it someday (and you will love it when it is). If you are worried about the security of the REST API, check the end of this article. If you get an error related to the REST API, it might be two things : it’s either that the WordPress REST API is not enabled, or that one of the requests to it was rejected or failed.

This article is being improved based on my users’ feedback. I will improve this troubleshooting little by little, so don’t hesitate to share your issues or your findings in the comments. Thank you 🙂

Is the WordPress REST API enabled?Enable PermalinksSecurity PluginsCheck your codeThe REST API is enabled, but it breaks, or the reply is broken?Is the WordPress REST API secure?

Is the WordPress REST API enabled?

The best way to check is to visit this URL: https://yoursite.com/wp-json. If you see some information which seems related to your WordPress REST API, it works. If you see something, it means that, at least, your WordPress REST API is enabled. Otherwise, that’s not working, and you will need to understand why.

If you are using one of my plugins (Meow Apps), don’t expect to see any information about it. My plugins only load their code when they are being used, for optimization purposes (and let’s say, additional security too!).

Visit your Settings > Permalinks. Make sure Plain is not selected. Usually, Post Name is the best choice. Even if everything is fine, click on Save Changes. That will rewrite/repair your .htaccess.

Security Plugins

Are you using a security plugin? They might block the REST API. Make sure it doesn’t. Known plugins to do that are :

  • WP Cerber Security
  • WPS Bidouille
  • Plugin Organizer

Check your code

Certain lines of code can be written to disable the REST API. If you find those, simply delete them.

add_filter('rest_enabled', '_return_false');
add_filter('rest_jsonp_enabled', '_return_false');

The REST API is enabled, but it breaks, or the reply is broken?

The reply might be broken. That means either an error has happened on the server side, or that the server rejected that request.

  • To knows if it’s an error, check this: The PHP Error Logs.
  • To know if it’s a network/server issue (rejected or timed out request), check this: Check Network Activity with Google Chrome. It’s usually a good idea to talk with your hosting service in this case, as the might be able to help you and share with you more information.

Keep in mind that the error might be directly related to the plugin you are having a problem with. Any other plugin can interfere and break the request.

Is the WordPress REST API secure?

Like any software, it can’t be perfect. But generally, it is very secure, and constantly checked by security professionals for new vulnerabilities. In fact, when plugins (or new WordPress features) are built, developers have the choice of using the REST API or implement their own way to access the data. And you guessed it, the latter it much less secure.

Basically, do you prefer to have one hundred slightly hidden doors to access your house, or one big and obvious metal door covered with security cameras and alarm systems on it? Enable the REST API, make sure developers are using it to create new features, and believe me, you will sleep better at night 🙂

 


News: WP/LightRoom Sync 5.0

Here it is! This new version brings a lot of nice changes. You will have to update the old plugin in Lightroom, as it will not work with the new plugin in WordPress.

How to update?

There are two important things you have to do:

  • The WordPress plugin should have already been updated automatically to 5+. However, you will have to update the Lightroom plugin manually. The tutorial is here and the new version is accessible in your account, here: downloads. Make sure the Plugin for Lightroom is the version 5.0.0 (or more, of course).
  • A token will need to be generated. In the WP/LR Sync Publish Service, you will need to Logout, paste your token there (there is no login/password anymore), and Login.

img

Any issue? Don’t panic and contact me, we will make it work. And you can always rollback to the previous versions. The old plugin for Lightroom is still available in your downloads, and the old plugin for WordPress is available here, at the end of the page (it is 4.4.8).

What’s new?

The biggest change is the new protocol. The former two protocols (XML/RPC and REST) have been totally removed. The plugin now uses its own. It is much faster, uses natural requests without the need extra-encoding, and it is less prone to compatibility issues.

Previously, you had to use your login and password. Every time you changed the password, you had to update it in Lightroom as well. That is annoying. Worse, this data was kept in the Lightroom database and was also going through the network. This could be a security issue. Now those potential issues are all over: WP/LR Sync requires a token instead of your login/password. You will have to visit your User Profile on the WordPress side and use the Generate Token button and copy/paste it into the WP/LR Sync Publish Service. No need to ever update it, even if you change your password. And if someone steals your token, it’s not a problem.

img

Please check the new Explorer (actionable through the Settings). It is not a replacement to Real Media Library (if you are using that plugin), but the WP/LR Sync Explorer is really fast, linked directly to the WP/LR Sync database, and works out of the box.

img

Another cool feature is the possibility of ordering your images within a collection/gallery more easily. Of course, that depends on how you are handling this on the WordPress side, but now WP/LR Sync shares this order with the other plugins if they need. It works perfectly with the standard WordPress Gallery (and therefore, the Gallery Shortcode).

img

Of course, I recommend you to use the Meow Gallery as your gallery system, as it works perfectly with WP/LR Sync.

imgThe Meow Gallery

But of course, if any other gallery plugin wants to use the cool features of WP/LR Sync, it is possible (only the developer needs to be willing to do it).

There was also a lot of optimization done, along with little fixes, and enhancements.

I really hope you enjoy this new version! And if you want to help me and love the plugin, don’t forget that you can review it. Thanks a lot for all your support over the years.

 


How to: Make WordPress Faster & Optimize It

Basic RecommendationsExcellent Hosting ServiceRecent version of PHPRestrict the number of pluginsThe Empty Request TimeClean WordPress’ databaseClean WordPress’ files

Basic Recommendations

Excellent Hosting Service

This is probably the most important: you need a proper hosting service. You might be happy spending only 2$ or 5$ per month for it, however, do you need to spend many hours every month on backups (or even paying for it), making it faster, and fixing issues after a crashes or hacks? If you value your own time more, then it’s probably better to spend a bit more on your hosting service. Last but not least, avoid using a VPS if you don’t have an engineer helping you optimizing it. They are not optimized by default.

Here are my recommendations: the Best Hosting Services for WordPress.

Recent version of PHP

If your server is not using PHP 7 (or more) yet, ask for it. It will improve the performance drastically. WordPress will also soon require it.

Restrict the number of plugins

The plugins installed on your WordPress have a huge performance impact. It is by far what slows down your website the most.

Even the plugins supposed to make your WordPress faster might make it slower. The best examples are caching plugins, optimization plugins and others. They indeed might accelerate the browsing of your website through caching, but they will slow down your install, especially the experience you have when you are logged in.

Move whatever process you can out of your WordPress. I am not talking about moving your images but using external services for optimization and caching. Please check my articles about Images Optimization and CDN. Also, it’s better to have security handled by your hosting service (and Cloudflare). Security plugins slow down your installs and open their own share of security holes.

Use the minimum number of plugins possible. If a plugin has many options and features, avoid it. Use a light plugin which only does what you need. If it doesn’t exist, do you actually need that feature? Sometimes less is better. And faster, in this case 🙂

The *Empty Request Time*

This term doesn’t exist, Meow Apps made it up! 🙂 But basically, each time you load your website, the WordPress admin, or run a request to perform an action (asynchronously or not), the whole WordPress framework will be loaded. Along with it, all the active plugins will be loaded as well and those might run processes (such as updating the database, running tasks, etc). And finally, after all this, your request will be considered and performed (even if it is just to display a Hello World page). Scary, right?

Therefore, listing the posts in your WordPress will take the Empty Request Time (this scary process explained above) + the time it takes to list the posts and to organize them on a page.

Your goal is to limit this time to the minimum. If it is more than 2,000 ms, that will cause issues (you will get timeouts very often). Ideally, it should be less than 500 ms.

If you install any plugin from Meow Apps, visit the Dashboard under the Meow Apps menu and you will find the screen below. It runs automatically every 5 seconds and calculate the average as it goes.

img

This idea would be to let this run, check your score, disable one plugin, click Reset and wait for your new score. By doing this, you might find which plugins (or options) are slowing down your WordPress.

Clean WordPress’ database

Before cleaning your WordPress, make sure you have a backup for it. I recommend you BlogVault if you don’t have any yet.

Optimizing the database is very straightforward, it’s done by deleting the revisions, the drafts, and all that. You can use a plugin for that, but it’s not really needed, as it’s really simple. There is a nice article about all this here, and most of the content be below comes from it. Here it is.

Delete all the revisions with this SQL request:

DELETE a,b,c  
FROM wp_posts a  
LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id)  
LEFT JOIN wp_postmeta c ON (a.ID = c.post_id)  
WHERE a.post_type = 'revision';

Delete the auto-drafts:

DELETE FROM wp_posts WHERE post_status = 'auto-draft';

Optimize the WordPress tables:

OPTIMIZE TABLE `wp_commentmeta`, `wp_comments`, `wp_links`, `wp_options`, `wp_postmeta`, `wp_posts`, `wp_terms`, `wp_term_relationships`, `wp_term_tax

Disable the revisions and the auto-drafts by adding the following lines in the wp-config.php (not necessary):

define('WP_POST_REVISIONS', false );
define('AUTOSAVE_INTERVAL', 259200 );

Clean WordPress’ files

You can use Media Cleaner to remove all the useless Media entries you have. Even the free version does this! If you use the Filesystem method, you will clean even more useless files.

 


I have been asked those questions fairly often. How to manage galleries in WordPress? Or to keep Lightroom synchronized with the galleries? How to make sure those galleries will evolve and always work over time (when the theme is changed for example)?

Use the WordPress GalleryEnhance the WordPress GalleryManage Galleries in a more convenient wayWithout LightroomWith LightroomAny thoughts, questions, recommendations?

I will start with the most important point: avoid using plugin uploading and managing your images in a way that it is not natural to WordPress. Every image in your WordPress must be in the Media Library.

The best way to create a proper gallery is through the Add Media button in the Post editor. This will create a gallery shortcode containing the identifiers of the images, like this:

[ gallery ids=”1,2″ ]

There is a tutorial on WordPress website about this, here: The WordPress Gallery.

Sometimes, the theme makes those galleries nice. Unfortunately, themes are often forcing users to install heavy plugins to manage the galleries instead. Again, make sure you are using the WordPress Gallery.

There are two main choices. The first is to use CSS to style the galleries (there is an old but good tutorial about this here on TutsPlus). The second is to use a plugin that does those enhancements. I will try to keep a list of plugins that do it:

  • Meow Gallery: developed by Meow Apps, it is of course recommended by Meow Apps. This plugin can be installed or uninstalled at any time without impacting your website, it will just impact your galleries layouts and design while it is installed and active. It includes many layouts and options and is designed to be light and optimized.
  • Tiled Gallery Carousel without JetPack
  • Responsive Gallery Grid
  • Photospace Responsive
  • Waiting for input from users. I would like to compile a list of nice plugins here. Please let me know if you know any good plugins in the comments below.

Manage Galleries in a more convenient way

Using the Add Media button might not be the most convenient way. It is better to have a way to gather the images and reference them in this shortcode.

Without Lightroom

The only way is to make the Media Library more visually… usable 🙂 I can recommend only one plugin for now, and it is Real Media Library. It will help you organize your Media, Folders, and Galleries, then you will be able to generate shortcodes. If you know any other plugin that helps you managing media and galleries/collections, please let me know in the comments.

With Lightroom

When Lightroom is used, WP/LR Sync (a plugin that synchronizes Lightroom to WordPress) is a must. The collections you create in Lightroom will be directly usable in the WordPress Gallery shortcode, like this:

[ gallery wplr-collection=”1″ ]
[ gallery wplr-keywords=”10, 20″ ]

There is a “Collections & Keywords” screen in WP/LR Sync in WordPress that helps the users to create those shortcodes.

 


Learn: The WordPress Images Sizes & The Upload Process

What happens to an image uploaded to WordPress? How are the thumbnails are created? What are those WordPress Images Sizes? I will try to reply to those questions as simply as possible.

The Process of Uploading an Image into WordPressIn the FilesystemIn the WordPress DatabaseWhy is this happening?The Big Image TresholdThe Images SizesThe Standard Image SizesThe Additional Images SizesResponsive ImagesSupport in WordPressHow does it work exactly?

The Process of Uploading an Image into WordPress

When you upload an image to WordPress, a new entry is created in the Media Library. But behind this, it is slighty more complicated.

In the Filesystem

At least 4-5 files are added in your filesystem (more specifically, in the /uploads directory, where your WordPress is installed). Those files are known as thumbnails, as they are smaller than the original file you have uploaded. In your filesystem, it will look like this.

Image-Files-in-the-Filesystem

Your original file keeps its name. The additional thumbnails are suffixed with their new dimension. Here, we have a square (150×150), and the others are reduced version of the original file. In fact, when you are looking at your Media Library (in List Mode), it is that square (150×150) image which is used.

In the WordPress Database

A new media entry is created in the database, and the associated metadata is generated. This metadata is very important: it contains the information about the files which were created, such as their dimensions, and their location.

Unfortunately, that metadata is not shown by WordPress. If you are curious about it, you can install Media Metadata and you will see a new column in the Media Library.

Media-Library-Media-Metadata

Here, you can see that your metadata contains the information about your thumbnails. Each thumbnail is associated with a name. Here, it’s medium, large, thumbnail, and medium_large. They correspond to the Image Sizes which were active at the time of the creation of the files and the metadata. We will dig into the Images Sizes soon.

Why is this happening?

Simply because your original file would be usually too big to be used directly on your website. Indeed, there are many ways to use an image, for example as a preview image when your posts are listed (in which the image appears small), or maybe in very big when it’s used at the top of your article.

Your theme or the plugins you are using, depending on the situation, will pick a different image to work with.

The Big Image Treshold

We are not done yet! Since version 5.3, WordPress resizes automatically your original image if it is bigger than 2560 pixels in width or height. This new image is called myfilename-scaled.jpg. This image is the one which will be used in your WordPress. The original myfilename.jpg will be also there, part of your files, but not used anywhere.

The way they did it is actually quite confusing; if you upload images smaller than 2560 pixels, they will not be scaled. So you might end with a mix of files with -scaled included or not in their names.

I strongly suggest you to disable this feature, in order to keep your filesystem clean and totally under your control. For this, you can simply use the Perfect Images plugin. You can also use the following code.

add_filter('big_image_size_threshold', '__return_false');

The Images Sizes

Welcome in the messy world of the Images Sizes! 🙂

The Standard Image Sizes

It’s very easy to check the image sizes registered by default in WordPress. They are accessible under Settings > Media. There, you can modify their dimensions. By the way, I highly recommend you to check the Organize my uploads into month option!

WordPress-Media-Settings

But that’s not all. You probably noticed it before, but in the screenshot of the metadata I shared with you earlier, there was a medium_large size. It is not displayed here (even it is part of the standard sizes), and you can’t pick it anywhere. So why is it there? Why are you making everything so complicated, WordPress!? Well, it’s actually an attempt to make things a bit simpler (and they don’t tell you about it), and this size is used to enhanced the Responsive Images feature (check the section about it to learn more).

The Additional Images Sizes

And now, there are all the additional image sizes added by your theme and the plugins. For example, WooCommerce adds 3 more image sizes. They talk about this in their documentation: WooCommerce Image Sizes for Theme Developers.

Unfortunately, there isn’t a screen to see all this clearly, and it’s more or less totally out of your control. That said, using the little plugin Media Metadata, you can see the metadata and guess what are those image sizes. I am working on another plugin which will allow you to have more control over those additional image sizes.

Responsive Images

Nowadays, there are many ways of browsing a website, with many different kind of devices. When you visit a website at home, on your big screen and with a very fast connection, you would be probably happy to see beautiful and crisp, large images. However, when you are on a trip with a somewhat slower connection, you would prefer to see a smaller image (since your device has a small screen anyway), and maybe even lower quality.

Support in WordPress

Luckily, since WordPress 4.4 (back in… 2015!), there is support for Responsive Images. If your theme or plugins take advantage of this feature, then your images will be responsive images.

How does it work exactly?

This part is a bit technical. When an image is being written into the HTML through the WordPress system, instead of just a src in the img tag, a src-set is used. All your images sizes are added into this src-set. Then, automatically, the browser of the visitor will pick the best suited images, depending on the size of the screen and the device connectivity.

If you are curious, here is an example of an image with a src-set.

<figure class="wp-block-image size-large"><img loading="lazy" width="819" height="1024" src="http://website.com/wp-content/uploads/2020/09/autumn-in-japan-819x1024.jpg" alt="Autumn in Japan" class="wp-image-360" srcset="http://website.com/wp-content/uploads/2020/09/autumn-in-japan-819x1024.jpg 819w, http://website.com/wp-content/uploads/2020/09/autumn-in-japan-240x300.jpg 240w, http://website.com/wp-content/uploads/2020/09/autumn-in-japan-768x960.jpg 768w, http://website.com/wp-content/uploads/2020/09/autumn-in-japan.jpg 1080w" sizes="(max-width: 819px) 100vw, 819px" /></figure>

 


How to: Optimize Images in WordPress

How to optimize images or which CDN to use with WordPress are very common questions I get. Of course, they also need to be compatible with my plugins.

IntroductionImportant NotesAmazon S3JetPackThe SolutionsImage OptimizersCDN ServicesAll-in-One Solutions

Introduction

First, I will start with solutions to avoid absolutely. Then I will tell you what you should do, and then introducing the different solutions. If you are only looking for the best solutions and that you have a bit of budget for your website, you can go directly to the All-in-One Solutions section.

Important Notes

Amazon S3

Avoid using S3 with WordPress. Don’t even think about it. Not now. It was not meant to be used with S3, and even if there are plugins allowing you to do that, it is a hack. I don’t doubt it is an interesting idea, unfortunately, you will encounter many issues, with many plugins as many core functions of WordPress will stop working properly. Moreover, S3 is not a CDN. It will not make any website faster, worse, it might even slow it down (relatively to your hosting service quality). CloudFront (Amazon CDN) will be required to actually make it worth.

When WordPress natively handles remote storages, it will become safe to use. For now, stay away from it.

JetPack

Avoid using JetPack. It might look simpler at first, but it is better to handpick the best solutions for you instead of using a solution overloaded with too many features and restrictions. I am not saying it is necessarily a bad plugin, but I would go for lighter and more focused solutions.

The Solutions

You should use a CDN absolutely, that will give you the biggest boost in term of performance. Then, you can also use an image optimizer, though that is more tricky as it is not instant (the images need to be all processed) and your files get modified. You can also choose a solution that does everything, including the file optimization, on the server (All-in-one Solutions).

Use an Image Optimizer. Many sizes (thumbnails) are created by WordPress for every image you upload. They are usually heavier than they should and that is why it is really recommended to optimize them. This is usually done with a plugin which runs the optimization either on your WordPress install directly, or on a remote server. Your files will be directly modified.

Use a Content Distribution Network (CDN). This is a service that stores your static files (images, JS, CSS, etc) on very fast servers around the globe in order to serve them at the highest speed possible, the closest as possible to your visitors. A plugin will be required (or some kind of HTML rewriter), and all the links to your static files will be modified to go through the CDN instead. The CDN will automatically get the files from your server on the first requests (and will refresh those files regularly).

Image Optimizers

img

I have tested all those plugins successfuly.

  • EWWW Image Optimizer. The developer is really helpful, friendly and enthusiastic, and does his best for his clients. The plugin works very well and the pricing is kinder to the waller than other solutions. The downside is that the UI looks a bit clunky. Works with WP Retina 2x and WP/LR Sync.
  • ShortPixel. The developers worked with me on the compatibility very nicely. I used this plugin and it also worked perfectly for me. It’s simpler than EWWW but has fewer options and no free alternative. Works with WP Retina 2x and WP/LR Sync.
  • Smush Pro. They contacted me to work on the compatibility in the past, so it should still work. The plugin is simple and works well. However, I feel like it reset the optimized status of the images from time to time. Much simpler than EWWW, quite similar to ShortPixel actually. Should work with WP Retina 2x and WP/LR Sync.
  • Imagify. They have a friendly team and they are the same guys behind WP Rocket. It worked perfectly on my install, it is also extremely simple. However, it does not work yet with WP/LR Sync.

CDN Services

img

  • CDN77. The best CDN for me currently. It is amazingly fast, the system is very neat and easy to install. I am currently using it for my websites Haikyo and Offbeat Japan.
  • CloudFlare. If you are looking for a free alternative, then have a look at it. If you are looking for performance, the services above are better, but you can still use CloudFlare for security purposes (it has a lot of features).
  • Fastly. If you are looking for the best performance possible, and if you have a technical team and quite a lot of money, then you might be interested in it. Their speed is the most impressive.

All-in-One Solutions

img

Today, there are two solutions I recommend. They do it all, they optimize your content on their own servers (so they don’t modify your own files and don’t use your server to perform that job) and they serve them using a CDN. Of course, that is more pricey, but it worth it.

  • Optimole. Very easy to set up with their WordPress plugin. It works right away. They also have a very nice feature for photographers: the watermark can be added automatically added through their service, on the fly! I am using Optimole on the Meow Apps website.
  • ImageKit. Easy to integrate. You can open an account using this referral code: syue6870. You will get 10% off.

How to: Improve your SEO with WordPress

How to achieve good SEO? It’s actually simple. You probably don’t need a book, an expert, watching videos. You don’t need to lose your time and/or money. Following simple and logical recommendations is all you need.

SEO ChecklistCheck your SEOPlugins for SEOHire an SEO expert

SEO Checklist

  • Make sure your content is unique, interesting or useful, awesome and loved. This is the most important, by far. Don’t copy it from another website (that will destroy your SEO in the long term).
  • Try to have other websites to link to your website. Ideally, those websites are playing in the same sector as you do. They must be good and genuine websites.
  • Make sure your website loads fast. You need a good hosting service, and to have your static resources (like photos, scripts, etc) delivered instantly, through a CDN for instance.
  • The title of each page should be good and unique (relatively to your website), and enclosed in an h2 tag. Chapters or subtitles should go in h3 tags.
  • The first paragraph(s) is very important, make sure they are descriptive enough.
  • Use beautiful (and, if possible, unique) imagery. Make sure their filenames are a minimum descriptive (check Media File Renamer). The ALT should also contain a description, a title, or a short list of keywords.
  • Optimized for every device. Your website should be readable on a standard screen, but also on a little laptop, a tablet and a mobile phone.
  • If you are using WordPress, make sure the Search Engine Visibility option isn’t disabled (in Reading Settings).

Check your SEO

You can do this by yourself. There are many services for this, but I recommend using this one: SEO Site Checkup. You will recognize the items of my checklist. You can only analyze your website once with this service (except if you pay for it), but take your time. Fix your website, try again tomorrow. Search engines will follow at their own pace too.

Your website doesn’t need to achieve a perfect score. If you are above 70, I believe that’s good. If you are above 80, that’s excellent. If you are 100, you spent too much time on achieving this feat and are probably very disappointed in not getting as many visitors as you think you deserve. In that case, work on the two first items of my checklist.

For your curiosity, Meow Apps website achieves 97. I actually didn’t work specifically on the SEO, but I am making sure naturally that I respect my checklist.

Plugins for SEO

You actually do not need to use a specific plugin for SEO. They seem necessary, but they really aren’t. They will also slow down your website and make your admin messier (and you might lose focus on the important parts of it, which is… the content). The only useful feature an SEO plugin might bring is making sure the meta title and meta description are properly written. However, your theme should be doing this already.

I have personally used Yoast SEO and The SEO Framework. I found the latter much better, and much less obtrusive. Avoid using one and simply make sure your metadata is properly written.

Hire an SEO expert

Watch out! Most of them are here because it’s easy money. Really easy money. They will add your website to a system that checks it regularly and create beautiful monthly reports. Those reports are a distraction. What matters, is your Google Analytics, your number of visitors and pageviews.

They might do a few things but often, they will use black hat techniques, which you should run away from. They will deliver results for a few weeks, or months, but then will crash your website completely.

Keep in mind that this checklist above is what really matters. An SEO expert can’t modify your content, therefore, they aren’t able to make your website substantially better. What they can do is to make sure your website is technically perfect from an SEO standpoint, and tell you how to make your content better (quality, organization).

 


How to: The PHP Error Logs

Something wrong happened while you were using a plugin in WordPress (freeze, or something similar) or your website is crashing with a blank screen… or anything else? Checking your PHP Error Logs is the first reaction you should have.

The PHP Error Logs is not the Access Error Logs (which is the error related to your web server and not PHP).

This article is still being written and updated. Don’t hesitate to ask questions in the comments, we’ll try to share more useful information over time.

What is the PHP Error Logs?Where to find the PHP Error Logs?Hosting Service Admin PanelThrough WordPress directlyWith the Meow Apps DashboardWith a Dedicated PluginEnable the PHP Error Logs through WordPressAdditional Information

What is the PHP Error Logs?

PHP Error Logs contain errors related to programming errors but also memory, space, and timeout issues. They are really important to troubleshoot issues.

Please note that the PHP Error Logs is rarely empty (as warnings are also logged in them).

Where to find the PHP Error Logs?

Hosting Service Admin Panel

Usually, you can access them through the administration system shared by your hosting service (not the WordPress one; it can be Plesk, cPanel, or their own system).

Through WordPress directly

If you are lucky, your PHP Error Logs are accessible through WordPress. Depending on your hosting service, it might work, or not. If the file is not found, or empty, it’s probably that it is disabled. If you can’t find them, or if they are empty and you have issues, contact your hosting service and ask them for access to your PHP Error Logs (and if they are good, for troubleshoot about your issue at the same time).

With the Meow Apps Dashboard

The Meow Apps Dashboard reads automatically, if available, your PHP Error Logs, splits it into the different warnings and errors, color those messages and display them nicely. It’s the simplest way of checking the errros. The Meow Apps Dashboard is available in all the plugins by Meow Apps (it’s a common library to all of them).

img

Above, the PHP Error Logs seems empty or not accessible.

With a Dedicated Plugin

There are a few plugins which are made to read the PHP Error Logs. They work the same way as the Meow Apps Dashboard, usually a bit simpler, they just display whatever is in the file. You can try Error Log Monitor.

Enable the PHP Error Logs through WordPress

There are some ways to get the errors to be written to a specific files through WordPress. This also highly depends on how your hosting service is set up, and if they allow it to be done. Please give it a try! You can simply add this in your wp-config.php file, right before the /* That’s all, stop editing! Happy blogging. */ line.

// Enable WP_DEBUG mode
define( 'WP_DEBUG', true );

// Enable Debug logging to the /wp-content/debug.log file
define( 'WP_DEBUG_LOG', true );

// Disable display of errors and warnings
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );

Note: this code the one recommended officially by WordPress for debugging purposes.


How to: Check Network Activity with Google Chrome

You will need to use Google Chrome. You can do it using other browsers but Google Chrome is the most convenient.

Why you should check the Network Activity

This is an important check, especially when a plugin is performing asynchronous actions (long-running process).

How to do it

Open your Google Chrome’s “Developer Tools” (https://developer.chrome.com/devtools) and click on the Network tab. Starts the process again until the issue occurs.

Go back to the Network tab, filter by XHR (those are the asynchronous requests, basically the discussion between your browser and the server, after the website has been loaded). Click on red colored request or the last request that was executed (in the left column, it’s usually admin-ajax.php) and look at the right window, in the XHR and Preview tab.

img

The Response tab might contain something interesting, like an error, or a broken reply from the server (if it is HTML, that’s also an issue as the message from the server is usually tiny and using JSON format). Please also check the Console window (look at the top of this window), as it might have some interesting information as well.

Fix: Timeout Errors in WordPress

Those timeouts really depends on your WordPress install and your server. In fact, there are many different errors meaning that a timeout occured, and they are all slighlty different.

The Timeout Errors408 Request TimeoutError 524: A timeout occured504 Gateway TimeoutWhy does it happen?How to fix timeout errors?Optimize your WordPress installIncrease the Max Execution TimeBy modifying your PHP SettingsBy calling a function in PHP

The Timeout Errors

408 Request Timeout

This code means that the server shut down an unused connection.

Error 524: A timeout occured

Error 524 error indicates that Cloudflare made a successful TCP connection to the origin web server, but the origin did not reply with an HTTP response before the connection timed out. Typically, Cloudflare waits 100 seconds for an HTTP response. If the origin doesn’t respond in that time, Cloudflare closes the connection and you’ll see “Error 524: A timeout occurred”.

504 Gateway Timeout

This code indicates that a gateway or a proxy did not get a response in time from your server.

Why does it happen?

For each page load, or for each asynchronous requests, WordPress loads itself every time. It doesn’t sound very productive, but this is how PHP works. Therefore, all the plugins are loaded every time. They also sometimes perform tasks, check updates, etc. You understand how much important it is to optimize your WordPress.

Generally, servers kill requests when they exceed 30 seconds. Nothing else will be displayed to you, the connection will just be cut.

How to fix timeout errors?

There are a few solutions.

Optimize your WordPress install

In short, make sure you are using the latest version of PHP (at least, PHP 7), and that you are running the least amount of plugins. You can follow this tutorial to make sure your WordPress is as fast as it should be: How to: Make WordPress Faster & Optimize It.

Increase the Max Execution Time

By modifying your PHP Settings

That’s not easy, as you need to have access to your server, or a way to change your PHP settings. If you have access to your php.ini, you need to look for the max_execution_time variable and set it to the number of seconds you would like, 60 seconds for example.

max_execution_time = 60

If that doesn’t work, or can’t access your php.ini, you can also try to set this variable by using the .htaccess (at the root of your WordPress install). You can add this line.

php_value max_execution_time 60

If you set the value to 0 (instead of 60, here), the process will be allowed to run forever. Don’t do this, you will run into much bigger issues, extremely difficult to resolve.

By calling a function in PHP

This is generally not really recommended to do this. But if you know what you are doing, you can tell PHP that you would like the process to run for more time. For this, you could write this call in your theme, in the functions.php for example.

set_time_limit(100);

How To: Debug WordPress Errors

You are running into an error, something is not working as it should. You realized that WordPress is more complicated than it seems, that not every plugin is made to work with each other, and that your server is not always on your side 🙂 Take it easy, and enjoy the process of debugging. Also, be curious about how things actually work. I assure you, it will be much better this way, and soon, you’ll be an expert.

This article is still being written and updated depending on your feedbacks.

Here is the list of articles we have already wrote in order to help you tacke the most common errors:

 

 


Fix: Allowed Memory Size Exhausted

WordPress allows you to run as many plugins as you like. Therefore, it’s not really surprising to get this dreadful error:

Fatal error: Allowed memory size of 805306368 bytes exhausted (tried to allocate 130023440 bytes) in /wp-content/plugins/somewhere.php on line X

Why this error?How to fix it?Disable or Remove PluginsOptimize WordPress (Options & PHP)Increase the PHP Memory LimitContact your Hosting Service

Why this error?

PHP runs WordPress, your theme and your plugins. Basically, everything that makes your website. To avoid issues, the server only allows a certain amount of memory to be used by PHP for each task. If you encounter this error, it means that a task (such as a visitor going on your website) required too much memory, and the server halted it.

This allowed memory size is in bytes, so for clarity, this might be helpful.

  • Allowed Memory Size of 8388608 Bytes Exhausted = 8 MB
  • Allowed Memory Size of 16777216 Bytes Exhausted = 16 MB
  • Allowed Memory Size of 33554432 Bytes Exhausted = 32 MB
  • Allowed Memory Size of 67108864 Bytes Exhausted = 64 MB
  • Allowed Memory Size of 134217728 Bytes Exhausted = 128 MB
  • Allowed Memory Size of 268435456 Bytes Exhausted = 256 MB
  • Allowed Memory Size of 536870912 Bytes Exhausted = 512 MB
  • Allowed Memory Size of 1073741824 Bytes Exhausted = 1 GB

How to fix it?

There are many ways, but you should consider them in order.

Disable or Remove Plugins

This is probably the first thing you should try; have a look at your Plugins list, and try to disable the ones you don’t really need. Not only you will get rid of this error, but you will make your WordPress faster.

Optimize WordPress (Options & PHP)

If you really need all your plugins, take some time to check the options for each of them; maybe you could avoid some heavy processing? Also, make sure you are using a recent version of PHP (nowadays, PHP 7 is a must).

Increase the PHP Memory Limit

That’s the easiest (and laziest) solution. You should only do this after you really tried to optimize your WordPress install. You can increase the memory limit in your WordPress by adding this line in the wp-config.php.

define( 'WP_MEMORY_LIMIT', '256M' );

You can also try 512M but you shouldn’t go above that.

Contact your Hosting Service

If you can’t change your PHP version or your PHP Memory Limit by yourself (or maybe it doesn’t seem to be possible), you should contact your hosting service.

 

Scroll to Top