To add a thumbnail to a post in WordPress, you need to manually add a “featured image” from the post editor. It’s possible to automatically use the first image in a post as the post’s thumbnail. Many themes do this automatically. There are also plugins that do this; one such plugin is Auto Post Thumbnail. However, if you don’t want to download a whole plugin, you can simply use the snippet below…
There are some plugins that are only used for specific pages on your blog. If you enable them globally, they will slow down the rest of your blog. WordPress doesn’t come with a built-in feature to conditionally enable plugins. I can’t even find a WordPress plugin that does this.
If you want to enable a WordPress plugin for just a single page, add this snippet to your
For example, I’m using The SEO Framework as my SEO plugin…
APC consists of 2 parts: opcode caching and memory caching. PHP 5.5 and newer have built-in opcode caching, so APC is no longer supported. A new PECL package, APCu, was created for the memory caching part. The prefix for APC memory caching functions changed from “apc” to “apcu”. For example,
Some plugins, such as W3 Total Cache, are still using the
Today I installed Query Monitor and noticed that each post on my homepage was triggering 2 database queries. One query retrieved the
post_tag post taxonomy and one retrieved the
post_format post taxonomy. Since my homepage has up to 15 posts, there can be 30 extra queries. These values should have been fetched all at once; they should not be fetched from the database individually.
I disabled my plugins one-by-one and realized that the issue was caused by W3 Total Cache…
WordPress allows you to write comments on media attachment pages by default. Since attachment pages contain only the attachment, it’s unlikely that people will write comments on them. The snippet below disables comments on attachment pages:
$is_open is already
false, this doesn’t fetch the post…
WordPress’s TinyMCE editor makes all links use absolute URLs with your blog’s
siteurl as the base. Your blog’s
siteurl is the value in Settings > General Settings > WordPress Address (URL). This value is hardcoded in your posts. This means that if you change your domain, change your permalink structure, or switch from http to https, you’ll have to update your posts. Also, you cannot support both http and https; you have to choose one…
WordPress loads jQuery from your server by default. It’s much better to load jQuery from Google’s CDN (content delivery network). Here are the 4 main reasons:
- Your visitors probably already have jQuery from Google’s CDN cached. This means jQuery will load nearly instantly.
- It’s probably faster to load jQuery from Google’s servers than your servers. They have faster servers and better networks. They also probably have a data center that’s closer to your visitor.
A post excerpt is a summary of your post. You can write an excerpt or let WordPress use the first few words of your post as the excerpt. Excerpts are at most 55 words by default, though you can change it by using the following snippet.