ACF fields audit with SEOKEY

Advanced Custom Field is a plugin that lets you add additional fields for writers.

Before SEOKEY 1.8, our SEO plugin didn’t allow you to analyze elements other than the main WordPress editor ( through blocks or TinyMCE). Now, if you use ACF, you can easily analyze all content.

Fields covered

SEOKEY allows the following fields to be analyzed by default, including within repeaters:

  • text
  • textarea
  • email
  • url
  • wysiwyg
  • image
  • gallery

Activating the analysis is simple. In ACF’s menu, edit the relevant field and activate the analysis option:

Option to analyze an ACF field with SEOKEY

Hooks

Of course, we’ve added two hooks so that developers can add as many fields as they like, even if they’re not part of the default list.

Since: version 1.8 (Free and PRO versions)

Hooks :

  • To add field types: filter seokey_filter_acf_allowed_types ( $allowedTypes )
  • To specify final content to be audited : filter seokey_filter_acf_content_to_audit ( $content_to_add, $acf_field )

Example

In this example, we add a user to audit:

Add User field to auditable fields :

// Add our ACF field type to the allowed fields
add_filter( 'seokey_filter_acf_allowed_types', 'my_seokey_function_to_add_ACF_fields', 10, 1 );
function my_seokey_function_to_add_ACF_fields( $allowedTypes ) {
    array_push( $allowedTypes, 'user' );
    return $allowedTypes;
}

Adding final content to the audit :

// Add this field type to the SEO audit
add_filter( 'seokey_filter_acf_content_to_audit', 'my_seokey_function_for_added_ACF_fields', 10, 2 );
function my_seokey_function_for_added_ACF_fields( $content_to_add, $acf_field ) {
    // Check the ACF field type we need
    if ( $acf_field['type'] === "user" ) {
        // Add the content that we need for the audit for that specific ACF field
        $content_to_add .= ' <img src="' . esc_url( $acf_field['value']['user_avatar']  ). '" alt="author image" /><span>' . esc_html( $acf_field['value']['display_name'] ) . '</span>';
    }
    return $content_to_add;
}
Cet article est-il utile ?
Updated on 12 November 2024
Table of contents
Shopping Basket
  • Your cart is empty.
Scroll to Top

Faites vite, l'offre est valable jusqu'au novembre 26, 2022 !

Days
Hours
Minutes
Seconds