-
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>
The ticket ‘rank math does not recognize content from acf custom block’ is closed to new replies.