rank math does not recognize content from acf custom block

#521727
  • Resolved Perry Anderson
    Rank Math free

    I have just switched to Rank Math after realizing that Yoast did not recognize content from Advanced Custom Fields. After installing your plugin, which definitely seems promising, I am experiencing the same behavior. The content in question is a custom ACF Block and the relevant code is listed below for your reference.

    I have enabled the ACF option in the plugin settings, and by ACF data appears on screen as it should. However, the plugin does not recognize any of the data.

    I do not believe it is a theme related issue. I have tested using default wordpress 2023 theme and get the same result. My active theme is a child of Astra. Below is the php file for the ACF block in question.

    Please advise. I’ve spent three hours searching for a solution. All articles found seem to relate to repeater and meta data.


    <?php
    /**
    * Info Box From Post Block Template.
    *
    * @param array $block The block settings and attributes.
    * @param string $content The block inner HTML (empty).
    * @param bool $is_preview True during backend preview render.
    * @param int $post_id The post ID the block is rendering content against.
    * This is either the post ID currently being displayed inside a query loop,
    * or the post ID of the post hosting this block.
    * @param array $context The context provided to the block by the post or it's parent block.
    */

    // Create class attribute allowing for custom "className" and "align" values.
    $class_name = 'info-box-from-post-block';
    if ( ! empty( $block['className'] ) ) {
    $class_name .= ' ' . $block['className'];
    }
    if ( ! empty( $block['align'] ) ) {
    $class_name .= ' align' . $block['align'];
    }

    // Load values and assign defaults.
    $site_name = 'Orchard Oven';
    $recipe_to_display = get_field('recipe_to_display') ?: '';
    $article_title = get_the_title( $recipe_to_display ) ?: 'Article title goes here ....';
    $site_excerpt = get_the_excerpt( $recipe_to_display ) ?: 'Site excerpt goes here....';
    $site_url = get_the_permalink( $recipe_to_display ) ?: 'Site url goes here....';
    $image_url = get_the_post_thumbnail_url( $recipe_to_display ) ?: 'Image url goes here....';

    // Build a valid style attribute for image background.
    /* $styles = array( 'background-image: url(' . $image_url. '); ', 'background-color: #cccccc; height: 400px; background-position: center; background-repeat: no-repeat; background-cover: cover; ');
    $style = implode( '; ', $styles ); */

    ?>
    <div class="<?php echo esc_attr( $class_name ); ?>">
    <div class="image-div">
    />
    </div>
    <div class="article-source">Courtesy of: <?php echo esc_attr( $site_name ); ?></div>
    <h3 class="title-heading"><?php echo esc_attr( $article_title ); ?></h3>
    <div class="excerpt-div"><p><?php echo esc_attr( $site_excerpt ); ?></p></div>
    <div class="anchor-div">
    " target="_blank">view recipe ->
    </div>
    </div>

Viewing 3 replies - 1 through 3 (of 3 total)
  • Nigel
    Rank Math business

    Hello,

    Thank you for contacting Rank Math for help with integrating ACF with Rank Math.

    If you haven’t already, please refer to our guide for integrating Rank Math https://rankmath.com/kb/automate-faq-schema-with-acf-repeater-fields/

    Hope that helps. Please let us know if you have questions.

    Thanks for the response but as I stated I am using ACF custom block, not a repeater. Documentation on handling blocks is pretty poor.

    Hello,

    Our plugin includes support for the default ACF blocks that come bundled with the ACF plugin.

    For any custom ones you might need to perform the actions here for them to be detected by the Content Analysis API: https://rankmath.com/kb/content-analysis-api/

    You can refer to the example we include for custom fields to learn more about how to implement this.

    In case you are not familiar with this, you will need to hire a developer that is confident working with WordPress to assist further with the implementation.

    Don’t hesitate to get in touch if you have any other questions.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 3 replies - 1 through 3 (of 3 total)

The ticket ‘rank math does not recognize content from acf custom block’ is closed to new replies.