ACF & RankMath: Automating Your Page Titles & Meta Descriptions

For many years, Yoast SEO has been my go to plugin for optimising WordPress websites. Until recently, I have switched to RankMath which is a feature rich SEO plugin with more features than Yoast. The ability to add Schema to posts and pages easily as well as the speed of the plugin makes RankMath a clear winner. One of the features of the plugin I’ve been using recently is the ability to pull in sections of Advanced Custom Fields into the page titles & meta descriptions, which is really handy for optimising dynamic sections of a website.

Today I’m going to be running through creating automated page titles and meta descriptions using Advanced Custom Fields and RankMath.

Examples

I have taken two examples in which I have used ACF and RankMath to create page titles and meta descriptions automatically, one for the properties available on an estate agent’s website and another for a listing on an alpaca breeder’s website. As new properties and alpacas are added to the website at any given time, the ACF & RankMath solution allows these pages to be automatically optimised without the need to wait for the new pages to be picked up for manual optimisation by the SEO team.

 

Estate Agents

Code for page title: %customfield(_bedrooms)% Bedroom %customterm(property_type)% %customterm(availability)%, %customfield(_address_street)%, %customterm(location)% %sep% J&H

Breaking down the above code, %customfield(_bedrooms)% pulls in the number of bedrooms that the property has as a single numeric value, %customterm(property_type)% then defines the property type, whether this be a semi-detached house, terrace or bungalow, %customterm(availability)% displays if the property is for sale or to let, %customfield(_address_street)%, %customterm(location)%  display the street the property is on followed by the town/city.

Page title generated on front end: 3 Bedroom Semi-Detached House For Sale, Orchard Green, Alderley Edge | J&H

Code for the meta description: Jordan & Halstead are proud to present this %customfield(_bedrooms)% Bedroom %customterm(property_type)% %customterm(availability)%, located at %customfield(_address_street)%, %customterm(location)%. Book a viewing today!

Similar to the page title code, the meta description calls on the number of bedrooms variable, property type, availability, address and also location.

Meta description on front end: Jordan & Halstead are proud to present this 3 Bedroom Semi-Detached House For Sale, located at Orchard Green, Alderley Edge. Book a viewing today!

 

Alpaca Breeders

Code for page title: %title% %sep% %customfield(sex)% %customfield(type)% %sep% %customterm(alpaca_statuses)% %sep% %sitename%

Breaking down the above code %title% pulls in the name of the listed alpaca, %sep% adds a separator to the title like ‘-’ or ‘|’ depending on what is defined in RankMath, %customfield(sex)% pulls in the sex of the alpaca, %customfield(type)% then displays the breed of alpaca followed by %customterm(alpaca_statuses)% which includes if the following is an alpaca for sale or an alpaca for stud. Finally %sitename% pulls in the sitename from the WordPress install.

Page title generated on front end: Fantasia | Female Huacaya | Alpacas For Sale | GB Alpaca

Code for meta description: Meet %title%, a %customfield(sex)% %customfield(type)% Alpaca. %title% is one of our %customterm(alpaca_statuses)% here at GB Alpaca. Find out more and arrange a visit.

Similar to the page title code, the %title% variable includes the name of the alpaca, %customfield(sex)% pulls in the sex of the alpaca followed by %customfield(type)% which includes the breed of alpaca. %customterm(alpaca_statuses)% finally pulls through if the alpaca is for sale or for stud.

Meta description on front end: Meet Fantasia, a Female Huacaya Alpaca. Fantasia is one of our Alpacas For Sale here at GB Alpaca. Find out more and arrange a visit.

How to Identify Custom Fields

Using ACF to create page titles and meta descriptions is easier than you’d think, the first step is identifying the custom fields that are in use on the page. The screenshot below is an example of the custom fields used on alpaca listings on the website taken from the field groups section of the ACF plugin.

RankMath uses the name field to identify each field, so from the above list if I wanted to display the colour of the alpaca in the page title or meta description, I would include the following; %customfield(colour)%. Likewise if I wanted to display the date of birth of the alpaca I would include %customfield(date_of_birth)%. It really is as easy as that, it will require some testing to ensure that you get the titles and meta descriptions to how you would like them, for certain cases such as if you want to display the price, you may have to include the currency symbol first before including the custom field variable like so: £%customfield(price)%, without the symbol the price will be pulled through as numeric value with no currency defined. Once you have built your page title & meta description template with your configured variables, it is simply a case of adding the page title and meta description to the relevant post type in the titles and meta section of RankMath. This will then set the titles and meta data for all pages within that post type to follow the new structure as well as set it for new pages/posts added within that type.

Summary

Automating your page titles and meta descriptions with ACF is easy, it saves time and also means that when a new dynamic page is added to the website, the page titles and meta descriptions are already optimised for SEO without having to be optimised manually once picked up by the SEO team.

Latest

Latest News & Blogs