• My website was created using Advanced Custom Fields and a variety of blocks that are registered using the acf_register_block_type() function. This plugin shows the wrong content when I use the_excerpt() in the WordPress loop, it looks like it’s duplicating content that exists on other pages when I search. My settings are “Index Visible Custom Fields”, “Create Custom Search Result Snippets”, and “Use Custom Fields for Excerpts”.

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Mikko Saari

    (@msaari)

    This problem isn’t just the excerpts, it’s also indexing. That wrong content is also used in indexing.

    Is all the ACF content included in the blocks? If that’s so, try disabling custom field indexing and custom fields from excerpts. Rebuild the index and see what happens.

    Relevanssi doesn’t need to read custom fields in order to read the ACF block content, Relevanssi renders the blocks in the post content.

    Thread Starter anthonypg

    (@anthonypg)

    The blocks use various ACF fields for their display. When I set Custom Fields to none and Use Custom Fields for Excerpts to false I get the same results.

    Plugin Author Mikko Saari

    (@msaari)

    And you rebuilt the index afterwards? If you look at the posts with the Relevanssi debugger, is the content still showing the wrong stuff for the blocks? If it’s still wrong, then there’s some problem in how the blocks are rendered. There shouldn’t be any inherent incompatibilities with Relevanssi and ACF blocks; I’m using ACF blocks myself and Relevanssi indexes the rendered blocks fine.

    One possible cause is if there’s some kind of post loop in your blocks. In that case, it’s possible the global $post gets mixed up and makes the wrong content show up. But it’s hard to say anything more specific about that… You can use the relevanssi_block_to_render filter hook to see the blocks before Relevanssi renders them and relevanssi_rendered_block after the rendering, those filter hooks might be helpful for debugging this.

    Thread Starter anthonypg

    (@anthonypg)

    Yes, I’ve been rebuilding the index every time I modify the options. This is what shows up in my debug screen, some of these words aren’t even on this page. One of my blocks includes a post loop, but it’s only used on one page and I’m using wp_reset_postdata() and wp_reset_query() before and after the loop in that block template.

    Plugin Author Mikko Saari

    (@msaari)

    I would go with the relevanssi_block_to_render and relevanssi_rendered_block hooks. Take a post that gets the wrong content and take a look at how Relevanssi sees the blocks when indexing it. Does relevanssi_block_to_render see the right blocks? Do they get rendered correctly, does relevanssi_rendered_block show the right content or not?

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

The topic ‘ACF Gutenberg Blocks the_excerpt Broken’ is closed to new replies.