Advanced Custom Fields On Archive Pages In Oxygen

Updated On
19-Jan-2020
By
Liz Jamieson

It's easy to set up custom fields wherever you need them, using the Advanced Custom Fields plugin. Together with Oxygen Builder, I used the plugin to create a simple layout for my archive pages on this website. The archive page layout can be seen here.

You can make archive pages more useful and more attractive, by adding advanced custom fields

My Archive Page Layout

I decided to use Oxygen's Easy Posts block in my archive layout. But right now, you cannot parameterize it for the query, (the posts that will contribute to each archive page). This meant I had to create a different template for each archive page, just to control which posts would be included. As I will only need three, or possibly four category archive pages, this wasn't a problem for me.

My category archive templates required the following custom fields.

Archive Title

You don't have to be stuck with the default category name!

By default each category already has a name which can be used as the title. But if the name of the category is blog, the title ends up being Category : Blog. I didn't want the word "Category" to appear in the title, so instead I created a text field called Archive Title using Advanced Custom Fields (ACF).

Archive Introduction

You can add an archive description but it strips some HTML.

By default each category already has a description which can be used as the introduction to the category page.

If you want to add HTML to the archive description, all but the most basic HTML is stripped.

So I created the text field Archive Introduction using ACF in order that I could maintain any HTML that I may have wanted to add, in the text in the field.

Archive Hero

Lastly I wanted an image to appear at the top of the each archive page. To this end I created a URL field using ACF. The URL would refer to an image that I had prepared an uploaded for each archive.

Advanced Custom Fields On Archives In Oxygen

Oxygen doesn't properly recognise when an Advanced Custom Field is added to an archive. In my opinion this is a bug or maybe I just don't understand what it going on, which is a possibility.

Any ACF archive fields that are added, appear in the group of post fields but are missing from the group of archive fields on the Oxygen interface. This does not seem right to me.

Using The Insert Data Button

When you try to insert archive ACF data using the provided button, it fails to insert the related data. To get around this you you have to use the PHP function facility. Provide values in this manner:

Please note that when adding this to the Oxygen interface, there is no space after the comma. Currently, if you include a space it can't find the custom field and returns with a no data message.

linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram