WordPress: Site not Secure despite SSL Certificate

I’ve recently migrated all my sites to use SSL (I know, it’s long overdue) and despite the SSL-Certificates being valid and working, Chrome and Firefox would show my sites as “not secure”. (No padlock icon.)

After some digging, I discovered that WordPress really doesn’t play very nicely with SSL. Lots of themes, plugins, etc will use hard-coded or generated, absolute, http:// URLs, with no regards to what the site is actually using. Worse, posts may include absolute URLs in links to content.

Instead of fixing all themes, plugins, and content manually (or with a clever script), one easy solution is to include the following line in your .htaccess:

Header always set Content-Security-Policy "upgrade-insecure-requests;"

This will cause the users’ browsers to convert all insecure http-Links to https automatically. So far, it seems to work perfectly fine.

Blogger/Blogspot can’t detect WordPress RSS feed

So I just had an interesting problem where a Blogger/Blogspot blog I help maintain couldn’t detect the RSS feed of a WordPress blog I help maintain.

The error message was “Could not detect a feed for this URL”.

It turns out the problem was two-fold. First: One of the files in the WordPress theme added an empty line at the top of the RSS feed.

Second: I had to update a post on the WordPress blog because *something* in the entire chain was caching the RSS feed!

So, if you have the same problem, run your RSS file through a validator, check if there are any leading empty lines, and make sure to update some post to regenerate the feed to avoid caching.

WordPress Images Not Showing

Another odd problem I had when migrating a WordPress blog to a new server is that some images would not display. It wasn’t that no image were showing; only some did not display. I have not found the root cause, but a solution.

It turns out that something happened to the thumbnails, i.e. resized versions of images. The easiest solution was to force WordPress to regenetate them.

For this, I used the Regenerate Thumbnails plugin by Alex Mills. Make sure to disable the option “Skip regenerating existing correctly sized thumbnails (faster).

After the plugin completed, all images were showing correctly again.

WordPress Redirect Loop

I’m currently in the process of migrating WordPress to a new server, and I made a somewhat silly mistake.

Basically, after setting up my virtualhost, wordpress, etc I ran into a redirect loop, where the site would always redirect from the actual name of my blog (“example.com”) to a signup page, and the signup page would then redirect to itself.

I was at my wits’ end, so I enabled debugging by adding:

define('WP_DEBUG_LOG', true);

and changing this line to “true”:

define('WP_DEBUG', true);

This creates a logfile called “debug.log” in your wp-content subdirectory.And lo and behold, it turns out I had forgotten to actually import my MySQL data.

18-Nov-2018 10:07:46 UTC] WordPress database error Table 'wordpress.wp_blogs' doesn't exist for query SELECT blog_id FROM wp_blogs WHERE domain IN ( 'blog.example.net' ) AND path IN ( '/wp-signup.php/', '/' ) ORDER BY CHAR_LENGTH(path) DESC LIMIT 1 made by require('wp-load.php'), require_once('wp-config.php'), require_once('wp-settings.php'), require('wp-includes/ms-settings.php'), ms_load_current_site_and_network, get_site_by_path, get_sites, WP_Site_Query->query, WP_Site_Query->get_sites, WP_Site_Query->;get_site_ids

I know how it happened – I redid my migration from scratch and took a break of a few days just before that step – and it’s unlikely someone else might run into this exact problem.

However, the steps to debug it are still valuable – had I done that in the first place, I might have saved myself quite a bit of time.

How to Disable WordPress “Prove your Humanity” captcha code question

A while back, WordPress introduced an annoying little feature, where you have to solve a simple math question in order to log in to your site:

I ignored this for a while, but decided it was too much of a hassle wile offering no real benefit. However, finding a way to disable it is not very intuitive, as it is not actually a core WordPress feature, but rather one added with Jetpack. It’s part of the Protect module:

Disabling Protect disables the captcha.

If you don’t see it on the main Jetpack page, click on the “See all xx Jetpack features” button:

and search for it:

After disabling, you’ll no longer get asked any nagging math questions on login:

PLEASE NOTE: Disabling this feature may decrease security for your site. Use your best judgement!

Adding Blog as a Menu Item in WordPress

On my personal blog, I set the main page to a static page. However, I also wanted a menu item to the blog posts. There was nothing in the Menu editor, but the solution is quite easy if you know how.

  1. Create and publish an empty page. I called mine “Blog”.
  2. In (Dashboard) -> Settings -> Reading, there is a drop down called “Posts page”. Select the empty page you just created. Save your changes.
  3. Under Appearance -> Menu add the Posts page to your menu. Save the menu.

When you now click on this menu item (or navigate to the page some other way) it will show the blog posts list as normal.

WordPress: Images not displaying, Redirects not working

Moved my WordPress installation to a new server. I kept all paths etc intact, copied my VirtualHost and permissions were good, so I was at first surprised when my images didn’t show and redirects didn’t work. The cause was quickly found, however; it seems my old install had different default settings hidden somewhere in the Apache configuration.

I guess there may also be different causes, but in my case I fixed it by adding this to my WordPress VirtualHost:

<Directory “/var/www/wordpress/”>
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all

/var/www/wordpress is obviously the DocumentRoot of my WordPress install.

Lo and behold, my WordPress site wasn’t broken anymore.

WordPress Error “please fill the required fields (name, email).”

I have been having a problem with one of my WordPress blogs that had me stumped: Whenever I would comment on it, being logged in as my WordPress user, I would get the error message:

“please fill the required fields (name, email).”

This started happening out of nowhere, without any connection to an update as far as I could tell. I even went so far as to check the code of my child theme – nothing. And I could not find any matching posts on the WordPress forums either…

It turned out to have a very simple solution. I disabled Jetpack, re-enabled it, and authorized Jetpack with WordPress.com again and lo and behold, the problem is gone.

No idea what the actual cause was, but this was one solution I did not try for some time – so I hope this helps anybody who is similarly stuck. 😉

WordPress Image Scaling Incorrect

I just noticed that WordPress is not resizing images correctly: It would appear correct in the blog itself, but the IMG SRC tag would link to the original, unscaled image: This meant that the image was downloaded at the maximum size and scaled on the client side. I never really noticed this because modern PC’s – even my outdated one – have enough processing power to just do it on the fly and browsers use quality scaling filters that smooth out the pictures.

Still, it makes the site unnecessarily slow. After some investigation, I found out that it looks like WordPress uses 32MB of memory by default – and that’s really not much.

Editing your wp-config.php file, you can add the line:

define(‘WP_MEMORY_LIMIT’, ’96M’);

to increase the limit. I decided on 96MB for a start, but maybe 64MB will be enough for you – I’ll leave that to you.

Anyway, now WordPress scales images I upload correctly. It won’t fix older images, but I can live with the big pictures in my archives.