Skip to main content

Install & Enable AMP Auto Ads by AdSense Labs in Worpdress – How To

If you’re a Google AdSense user you will probably know about AdSense Lab, the incubator hosting those brand-new Ad-based features that aren’t yet ready to be rolled out to all AdSense publishers. The new deal these weeks is called AMP Auto Ads, a new family of advertising units that will be placed automatically within the AMP pages of our website/blog.

In the unlikely event you dont’ know what an AMP page is or if you never heard about the AMP Project, we strongly suggest to fill this huge SEO & accessibility gap by taking a look at the AMP Project’s official page.

The AMP Auto Ads feature is currently in beta and thus accessible only for those who are explicitly invited via e-mail from AdSense Lab. For additional info, read this official guide from Google AdSense. However, since you are here, there’s an high chance you already know everything about AMP Auto Ads and you’re looking for further info about how to properly implement them on your WordPress website or blog.

Read More

WordPress – How to retrieve all posts from one or more given categories with a SQL query

Today a client asked me to remove all the posts from a given category to the auto-generated XML Sitemap of his WordPress blog and also redirect these posts to a new website (same slug, different host): here’s a quick report of how I managed to do that, hoping that it would also help other System Administration that will be given these same tasks.

Read More

How to fix “MySQL server has gone away”, “Packets out of order” and similar MySQL connection errors

If you’re a fond MySQL and/or MariaDB user you most certainly experienced at least one of these common errors:

MySQL server has gone away

Error reading result set’s header

Error executing query

MySQL server has gone away for query

2006, MySQL server has gone away

Packets out of order. Expected X received Y. Packet size=Z

… and so on. You can find these warnings basically anywhere, as they are usually written in the log files of the applications, tools and services that try to connect to your database and fail: however, in most scenarios, they are firstly noticed by the zealous System Administrator inspecting the PHP error log file (or the Joomla or WordPress counterpart) while trying to understand why his beloved web site or service isn’t working like it should.

That said, let’s try to understand the underlying cause and see what we can do to overcome them.

Read More

WordPress – How to redirect all posts in one or more Categories, having one or more Tags or other custom conditions

Being able to redirect a post to another URL is a common need of any WordPress-based Web Master: there are a number of good reasons for doing that, such as: splitting your blog, moving a post from a website to another or to a sub-domain, and so on. Luckily enough, there are a lot of good plugins that can help you to do that, such as:

… and so on.

Unfortunately, most of them are either working with an SourceURL > RedirectURL static list or by adding a widget in the Edit Post page where you can insert the target redirect URL and some additional parameters, such as the redirect type (301 or 302).

What if we need to redirect all posts matching a certain condition? Here are some examples:

Read More

PHP – How to fix the “Warning: preg_replace(): The /e modifier is no longer supported” error in PHP7

Here’s one of the most common issues when upgrading from PHP5.x to PHP7:

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead

Despite being a well-documented issue in PHP manual (deprecated since v5.5 and then unsupported since v7.0.0), the above warning is easily one of the most annoying backward-incompatible changes a developer could face when performing the upgrade: adopting the suggested fix – reimplement the code using the newer and more robust preg_replace_callback function – is not always easy, because the preg_replace usage together with the /e modifier was quite common among PHP-based scripts, apps and interfaces until few years ago.

In the following post we’re sharing three methods we can use to work around the problem: feel free to pick the one that is most suited for your specific scenario.

Read More

Close