WP Ref

WP Ref

  • Using the_title Filter to Change Post Titles When Displayed

    A useful filter WordPress provides is the_title. This filter allows you to edit the title, most often used before it is displayed. Here’s an example to see it in action. Let’s say you want to add “(New!)” to the title of your latest posts when they’re displayed. To do this, you can use the the_title…

  • Changing the Timezone in WordPress

    Every WordPress installation’s timezone is set to UTC+0 by default. Chances are your website isn’t based within UTC+0. The timezone is one of the most missed settings when managing websites, I’ve found (as I’ve explained in my article, “Overlooked Settings”). The problem with missing the timezone option is that none of the times displayed on…

  • How to Use get_posts to Retrieve the Posts You Need

    I can’t think of many functions that I use more often than get_posts. As a wrapper for WP_Query, get_posts provides a convenient way to retrieve just the posts you need. In this guide, I’m going to dive into all the different options you can use to retrieve the posts you need. In this article: Basic…

  • Using Anonymous Functions for Testing Hooks

    There are times when you just want to try some code for a hook, but can’t be bother to write a separate function or class method. This can certainly be the case for myself when I’m working with a class with many methods, or a long file. Trying It Out Let’s say we want to…

  • Overlooked Settings

    There are several settings I’ve been guilty of overlooking in the past when launching new websites. I want to share these settings with you so you can add them to your site launch checklist. In this article: The Settings Before I dive into some of my most commonly missed settings, it’s important to mention that…

  • Using var_export to Debug and Prettify Dumps of Anything

    When developing for WordPress (and anything in PHP in-fact), it can be incredibly useful to be able to dump values. Yes, there’s a function for that called var_dump, which is great… if you’re not dealing with anything complex. As soon as you output anything more complex such any type of array, object, or class instance,…

  • Plugin Headers

    Every WordPress plugin contains a plugin header. The plugin header is a multi-line PHP comment containing various details about the plugin. WordPress detects if a file represents a plugin if it contains a plugin header. The details in the header are used on the Plugins dashboard page. Here is the simplest example of a plugin…

  • Hooks — The Ultimate Guide

    Hooks are the bread and butter behind each WordPress website. A hook is an execution point where WordPress checks to see if there are any callbacks to run. There are two types of hooks: an action, and a filter. Use Cases There are many use cases for hooks. Hooks are convenient because you don’t need…

  • Creating Local WordPress Installations for Development Using Local

    When developing and extending WordPress, it’s important to have a great development environment from the get-go. I’ve tried all sorts of software solutions from WAMPP, to MAMPP, to installing a LAMP stack manually. By far the easiest development environment I’ve used thus far is an application called Local. Local is an application that runs on…