Example based WordPress Codex

WordPress Tips & Tricks

An archive of useful WordPress guides, showcasing tips and tricks for everyday WordPress development and usage.

Think of this page as the WordPress Codex, however, with examples and step-by-step tutorials on how to use specific functions.

How To Refresh Permalinks Automatically Without A Plugin

Looking to auto-refresh WordPress permalinks automatically, without a plugin? This guide will show you ow you…

View Guide

How to disable lazy loading in WordPress 5.5+

Looking to disable lazy loading in WordPress 5.5 or above? All you may need is to…

View Guide

How to disable WordPress redirecting missing 404 URLs

Looking to disable WordPress from guessing page-not-found URLs (error 404)? Here’s a quick guide on how…

View Guide

How to exclude post types from wp-sitemap.xml in WordPress

Looking to exclude post types or custom post types from the wp-sitemap.xml file in WordPress? Here’s…

View Guide

Removing specific posts from wp-sitemap.xml in WordPress

Looking to remove specific posts from your wp-sitemap.xml file? Here’s a quick and easy guide on…

View Guide

How to remove a taxonomy from the wp-sitemap.xml file

Looking to remove a taxonomy from the wp-sitemap.xml file in WordPress? Here’s a quick and easy…

View Guide

How to disable wp-sitemap.xml in WordPress 5.5+

Looking to remove the wp-sitemap.xml introduced in WordPress 5.5? Here’s a quick and easy solution on…

View Guide

How to add apple-touch-icons in WordPress

Are you looking to add apple-touch-icons in WordPress? Yet need to remove the default apple-touch-icon from…

View Guide

Using update_post_meta() to update an array

Are you trying to use update_post_meta() in order to try update post meta which is stored…

View Guide

Contact Form 7 emails reply to wrong email address

Do your WordPress Contact Form 7 emails reply back to the wrong email address? Here’s a…

View Guide

Contact Form 7 Keeps Spinning

Does your Contact Form 7 keep spinning and not send emails out? All you may have…

View Guide

Split CSV file & keep header line using Terminal on Mac

Looking to split a CSV file but keep the header line using Terminal on Mac? All…

View Guide

Change WordPress password through phpMyAdmin

Locked out of your WordPress website? Here’s a quick guide on how to change your WordPress…

View Guide

Using Google Chrome to capture post data in WordPress

Looking to capture post data in WordPress using Google Chrome? All you need to use is…

View Guide

Installing phpMyAdmin on Ubuntu with WordPress installed

Are you trying to install phpMyAdmin on Ubuntu with a WordPress site installed on the same…

View Guide

Using $ instead of jQuery in WordPress

Are you looking to use the dollar sign ($) instead of jQuery in WordPress? All you…

View Guide

How to add HTML to WordPress

Are you looking to add HTML in WordPress using the Gutenberg of classic editor? Here’s a…

View Guide

Displaying the site name or description in WordPress

Looking to display the site name or description in your WordPress theme? All you need to…

View Guide

Include custom post types inside WordPress search

Looking to include custom post type results inside the WordPress search results? Here’s a guide on…

View Guide

How to list post attachments inside a WordPress admin single

Looking to list post attachments made by Gravity Forms (or other plugins) inside the WordPress admin…

View Guide

Block wp-content/uploads folders

Trying to block the wp-content/uploads folder from being accessed publically, so that people can’t see your…

View Guide

What is the Content Editor?

Within WordPress, which section of the website is referred to as the content editor?

View Guide

What is a Post Type?

What is a Post Type (and custom post type) in WordPress and how do their templates…

View Guide

What is a Single?

When using WordPress, what is meant by the term single or singular and how do you…

View Guide

What is WordPress Gutenberg?

What is WordPress Gutenberg and what does it allow WordPress developers do?

View Guide

What is WPDB?

What is WBDB and what does it allow me to do in WordPress when using it?

View Guide

What is a Permalink?

What is a permalink and does it differ from a slug in any way within WordPress?

View Guide

Using wp_body_open()

The useful function introduced in WordPress version 5.2, wp_body_open() gives you the capability of running custom…

View Guide

Request header field x-wp-nonce is not allowed (preflight response)

Getting the error Access to XMLHttpRequest at ‘example.com’ from origin ‘www.example.com’ has been blocked by CORS…

View Guide

Using WPDB to connect to an external database

Looking to use WPDB to connect to an external database in WordPress? You just need to…

View Guide

Unknown collation ‘utf8mb4_unicode_520_ci’

Getting the error unknown collation ‘utf8mb4_unicode_520_ci’ when trying to upload your SQL file into phpMyAdmin? You…

View Guide

Changing the width of the Gutenberg editor

Looking to change the width of the Gutenberg editor in WordPress? A quick workaround is to…

View Guide

Using human_readable_duration()

Looking to use the human_readable_duration() in WordPress 5.1+? Here’s a guide on how you can call…

View Guide

Adding special characters into the rel attribute inside menu links

By default, WordPress strips out special characters inside its menu link’s relationship (rel) attribute. Here are…

View Guide

wp_reset_query() or wp_reset_postdata() after a custom query?

Trying to understand if you should use wp_reset_query() or wp_reset_postdata() after a custom WordPress query’s loop?…

View Guide

WordPress theme options reset after migration

Have your WordPress theme/template options reset after you’ve migrated from one domain to another? All you…

View Guide

$_POST submit button not working on Edge or IE

Is your $_POST superglobal submit button not working on Edge or Internet Explorer? All you may…

View Guide

Remove x-frame-options to sameorigin from iframe

Trying to remove/deny x-frame-options to sameorigin from an external URL, such as through an iframe? You…

View Guide

Visual Composer shortcodes not working

Are your Visual Composer shortcodes not working in WordPress, leaving you with bracketed shortcodes such as…

View Guide

Other pages showing as 404 but work with plain permalinks

Are your other pages showing a 404-error after you’ve migrated a WordPress website to another server…

View Guide

Logo appearing pixelated in Chrome

Is your WordPress logo appearing pixelated/fuzzy on a PC, only whilst using Google Chrome? All you…

View Guide

“Proper authorization is required to access this resource”

Getting the error “Proper authorization is required to access this resource” when using wp_remote_get() function in WordPress?

View Guide

Redirect WordPress to HTTPS using htaccess

In order to redirect your website to HTTPS using WWW or non-WWW, you can use this…

View Guide

Increase the nested comments level

Trying to increase the WordPress nested comments level? You can change this in WordPress or by…

View Guide

Including WordPress functions in a custom PHP file

In order to use your WordPress website’s functions in an external PHP file, you need to…

View Guide

the_date() not always working on archive page?

Is your date not displaying under specific archive page posts? You may need to use the_time()…

View Guide

Uploaded images become blurry after upload?

Are your uploaded WordPress images being displayed blurry after uploading them? This is due to the…

View Guide

Custom post type and page share the same URL

So you’ve accidentally named your CPT and page URL (the slug) the same? Here are a…

View Guide

Only allow the post’s author to comment

Looking to only allow the post’s author to comment on a blog post? All you need…

View Guide

Using get_template_part() in a shortcode

Looking to use get_template_part() inside a WordPress shortcode? All you may need is to use PHP’s…

View Guide

How to add Schema markup in WordPress

Looking to add Schema markup in WordPress? There are numerous ways that you could do this…

View Guide

Missing argument 2 for _x() error in WordPress

Has your WordPress website randomly developed a Warning: Missing argument 2 for _x() error? All you may…

View Guide

How to see if a website is build on WordPress

Are you trying to tell if a website is built with WordPress? There are many methods…

View Guide

How to change the site’s title in WordPress

Looking to change the website’s title? All you need to do is to navigate to your…

View Guide

Increase PHP max input vars in WordPress

Looking to increase PHP max input vars in WordPress? There are different methods you can use to…

View Guide

WordPress login not secure

Is your WordPress login showing as not secure? All you may need is to issue an…

View Guide

Automatically add new top-level pages to the menu

Looking to automatically add new top-level pages to the menu in WordPress? All you may need…

View Guide

How to add meta tags in WordPress

Trying to add meta tags to WordPress for SEO? This how-to guide will explain how you…

View Guide

Add expires headers to WordPress

Trying to speed up your WordPress website? You could try to add expires headers into your…

View Guide

jQuery $ is not a function in WordPress

Getting a jQuery error that $ (dollar sign) is not a function in your WordPress website? All…

View Guide

WordPress debug.log not created

Is your debug.log file not generating in WordPress? To create this, all you may need is…

View Guide

get_categories() not working in WordPress

Is your get_categories() function not working by showing any matches? You may need to allow the…

View Guide

Capitalise Yoast SEO meta titles

Trying to capitalise your meta title using Yoast SEO? All you may need is to filter…

View Guide

the_title() not working inside singles?

Having issues with the_title() not working inside any of your single post types? You may only…

View Guide

How To Remove Recent Comment Styles In WordPress

Looking to make your website AMP-friendly by removing recent comment styles in WordPress? You can follow…

View Guide

Fixing Common WordPress Security Issues

Trying to fix WordPress security issues? Here’s a guide to fix common issues and concerns you…

View Guide

Register A Custom Dashboard Meta Box

Looking to register a custom dashboard meta box? All you may need is to register a…

View Guide

WordPress Between Query Not Working Correctly For Numbers?

Is your WordPress between query not displaying the correct results for a numerical numbered integer value…

View Guide

How To Order WP Query By Multiple Columns

Looking to use orderby to order multiple WP Query columns? All you may need is to feed…

View Guide

Include PHP Variables Inside Template Parts From The Outside

Trying to include PHP variable inside the get_template_part() function from the outside? All you may need…

View Guide

How To Change The Yoast SEO Description Through The Function’s File

Looking to change the Yoast SEO description through the functions file dynamically? All you may need…

View Guide

Multiple $wpdb->insert Queries Not Creating Permalinks?

Is your $wpdb->insert multiple post query not generating any permalinks? All you may need is to add in…

View Guide

Change Yoast SEO Meta Title With $_GET Superglobal URL Parameter

Trying to change the Yoast SEO meta title dynamically using the $_GET superglobal URL parameter? All you…

View Guide

CSS Stylesheet Not Updating On WordPress Website

Is your WordPress style.css stylesheet not updating in WordPress, even after clearing your cache? You may…

View Guide

How To Search With Custom Meta Fields In WordPress

Trying to use your website’s search to include custom meta fields? All you may need is…

View Guide

the_content() not working on single post type

Is the_content() not working on your single post type? All you may need is to wrap…

View Guide

Uploading WordPress Plugins To An SVN Using A Mac

Looking for a guide to upload your new WordPress plugin to an SVN using a Mac?…

View Guide

How To Loop Through Post Categories In WordPress

Trying to loop through post categories? All you may need is to use the get_categories() function…

View Guide

Encrypting File Upload Names In WordPress Automatically

Trying to change and encrypt the file upload names automatically in WordPress using MD5? All you…

View Guide

Show The Hidden Settings Link In WordPress Admin

Trying to show the hidden settings in your WordPress website’s admin area? All you may need…

View Guide

Add New Custom Field Upon Post Creation

Looking to add a new custom field upon post creation? All you may need is to…

View Guide

How To A Paginate Custom Taxonomy Archive In WordPress

Trying to paginate a custom taxonomy query in WordPress due to a 404 error on /page/2?…

View Guide

How to paginate a custom post type in WordPress

Looking to paginate a custom post type in WordPress? All you may need is to pass…

View Guide

How To Count Total Number Of WordPress Posts

Looking to display the count of the total number of WordPress posts on your blog? All…

View Guide

How To Build A Cookies Policy Notice For WordPress

Trying to build a custom cookies policy notice for your WordPress website? All you may need…

View Guide

How To Remove The UL Tag From The WordPress Menu

Trying to remove the ul tag, including containers around the menu? All you may need is…

View Guide

How To Automatically Open WordPress Links In New Tabs

Looking to automatically open WordPress links in new tabs using the_content()? All you may need is to…

View Guide

How To Build A WordPress User Only Shortcode

Looking to build an exclusive logged-in user-only shortcode? All you may need is to copy this…

View Guide

How To Build A WordPress Shortcode

Need to build a custom WordPress shortcode? All you may need is to register the shortcode…

View Guide

How To Fix Error Establishing A Database Connection In WordPress

Have you encountered an Error establishing a database connection in WordPress? Here are some solutions to…

View Guide

How To Update WordPress Posts With AJAX On The Front-End

Looking to update posts, including custom post types on your WordPress website’s front-end through AJAX? This…

View Guide

How To Compare Between Two Dates In A WordPress Loop

Looking to compare between two dates in a WordPress loop? All you may need is to…

View Guide

Get Related Posts Based On The Post Content In WordPress

Trying to get the IDs of related posts based on the content of the post in…

View Guide

How To Display PHP Errors In WordPress

If you need to debug PHP errors in WordPress, it can really help to display them…

View Guide

How To Use get_template_part() In WordPress

Looking to use get_template_part() in WordPress? All you may need is to know how to call…

View Guide

How To Edit The WordPress Admin Footer Text

Looking to edit the WordPress admin footer text on your website? All you may need is…

View Guide

How To Query Posts With Meta Keys & Values In WordPress

Looking to query posts with meta keys and values in WordPress? All you may need is…

View Guide

How To Loop Through Post Types In WordPress

Trying to loop through a post type in WordPress? All you may need is to create…

View Guide

How To Register A Custom Post Type In WordPress

Looking to register a custom post type in WordPress? All you may need is to add…

View Guide

Open menu links in new tabs in WordPress

Looking to open a menu link in a new tab in WordPress? You may only need…

View Guide

How To Exclude Pages From Search In WordPress

Looking to exclude pages from your WordPress search functionality? All you may need is to add…

View Guide

Add New Users Without Logging Into WordPress

Ever need to add a new user without logging into the WordPress Dashboard? You can do…

View Guide

Change The Default Ending On WordPress Excerpts

Need to change the default ending on WordPress excerpts? All you may need is to add…

View Guide

Change Excerpt Length In WordPress

Need to change the default excerpt length in WordPress to make it longer or shorter. All…

View Guide

Disable Login By Email On WordPress

Ever need to disable the login by email functionality on WordPress websites? All you may need…

View Guide

Register custom menus in WordPress

Looking to add custom menus in WordPress for your custom theme? All you may need is…

View Guide

How To Use SVGs In WordPress

Trying to find out how to use an SVG file in WordPress? All you may need…

View Guide

How To Add Custom Logo Support In WordPress Themes

Looking to add custom logo theme support to your WordPress template? All you may need to…

View Guide

How To Change The Logo On The WordPress Admin Login

Looking to change the logo on the WordPress admin login page? All you may need to…

View Guide

How To Hide All Updates (Core, Plugins & Themes) In WordPress

Need to hide all WordPress updates including core, plugin and theme updates? All you may need…

View Guide

Edit wp_query to search by post title & meta value in WordPress

Trying to search the post title and meta value in WordPress at the same time inside…

View Guide

Migrate WordPress From HTTP To HTTPS

Wanting to migrate a WordPress website from HTTP to HTTPS? Follow these steps to migrate your…

View Guide

Media Image Upload Not Working In WordPress

Having trouble with your media uploader not working in WordPress? It may be that you just…

View Guide

How to edit .htaccess file without FTP access in WordPress

Looking to access your .htaccess file without FTP access on your WordPress website? All you may need…

View Guide

How To Increase Maximum Upload File Size for WordPress

Increasing the maximum upload file size for WordPress requires you to access your website’s server files.…

View Guide

Remove Category Prefix In WordPress Category Title

Removing the Category: prefix in WordPress category titles is possible. It may just be that you…

View Guide

Custom Post Type Single Page Not Working

Having issues with your custom post type (CPT) single page not working? Look no further, it…

View Guide

Get Taxonomy Name From ID In WordPress

Need to get the taxonomy name from its ID in WordPress? All you may need is…

View Guide

WordPress Meta Title & Description Tag Not Showing

Are your WordPress meta title and description tags not showing, even with Yoast SEO installed? All…

View Guide

How To Register Sidebars In WordPress

Looking to register a WordPress sidebar in your themes? All you may need is to add…

View Guide

How To Update A File After New Post Or Page In WordPress

Looking to update a text file after a new post or page creation in WordPress? All…

View Guide