---
title: How to integrate Advanced Custom Fields (ACF) with SEOPress
url: "https://www.seopress.org/support/guides/how-to-integrate-advanced-custom-fields-acf-with-seopress/"
lang: en-US
updated: 2024-04-10
---

# How to integrate Advanced Custom Fields (ACF) with SEOPress

SEOPress allows you to easily inject [many types of data into your SEO metadata](https://www.seopress.org/support/guides/manage-titles-meta-descriptions/). In this guide, we will explain how to use the values from your custom fields created with the third-party [Advanced Custom Fields](https://www.advancedcustomfields.com/) extension.

## Use “simple” custom fields in your SEO metadata

By default, a custom field can be used in a meta via this dynamic variable:

`%%_cf_your_custom_field_name%%`

Simply replace `your_custom_field_name` with the name/key of your custom field:

`%%_cf_seo_title%%`

This variable can be used in title tags, meta description, social (Open Graph / X) etc. It covers most field types in the Advanced Custom fields extension that use this function to be called:

`get_field('field_name');`

## Use ACF Options Page Custom Fields in Your SEO Metadata

If you build options pages with ACF, the function to retrieve stored data is:

`get_field('field_name', 'option');`

By default, you will not be able to inject these into your SEOPress metadata. We will need to create a new custom dynamic variable whose code is:

Copy and paste this snippet of code into your functions.php file or into a [must-use plugin](https://www.seopress.org/support/guides/how-to-create-a-mu-plugin/).

Then replace in the code:

- the names and keys given to the dynamic variables by those desired (lines 2,3, 18 and 19)
- the names of the ACF fields when called via `get_field()` (lines 10 and 11)
- your `text-domain` by yours for the translation (lines 18 and 19)

Below is an example with an options page created in ACF and 2 text fields:

[![Options page created with Advanced Custom Fields](https://www.seopress.org/wp-content/uploads/2024/04/seopress-acf-fields-options-page-seo-metadata-3.png)](https://www.seopress.org/wp-content/uploads/2024/04/seopress-acf-fields-options-page-seo-metadata-3.png)

*Options page created with Advanced Custom Fields*

[![Creation of 2 text fields with Advanced Custom Fields](https://www.seopress.org/wp-content/uploads/2024/04/seopress-acf-fields-options-page-seo-metadata-2.png)](https://www.seopress.org/wp-content/uploads/2024/04/seopress-acf-fields-options-page-seo-metadata-2.png)

*Creation of 2 text fields with Advanced Custom Fields*

Then the result in the SEO metabox and the Google preview showing our values dynamically retrieved from the ACF options page:

[![Using ACF fields from options pages in the SEOPress metabox](https://www.seopress.org/wp-content/uploads/2024/04/seopress-acf-fields-options-page-seo-metadata-1.png)](https://www.seopress.org/wp-content/uploads/2024/04/seopress-acf-fields-options-page-seo-metadata-1.png)

*Using ACF fields from options pages in the SEOPress metabox*

If you use the universal metabox, you will need to adapt the code as mentioned [here](https://www.seopress.org/support/guides/create-your-custom-dynamic-variable-for-your-meta-title-description-social/#standard-seo-metabox) to see the dynamic variable appear in the drop-down list. It remains optional to use it.
