AdvancedCustomFields / AdvancedCustomFields/acf

[Question / Feature request] Gutenberg block with repeater field on external page

Open
#521 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
945
Forks
197
PR merge metrics
No merged PRs in 30d

Description

We have posts with blocks. Some blocks have ACF repeater fields.

however we can't acces those fields on archive page.

we have following code to get the field data:

function get_field_from_block($post, $block_name = 'core/heading', $field_name = "" ){
	$content = "";
	if ( has_blocks( $post->post_content ) && !empty($field_name )) {
	    $blocks = parse_blocks( $post->post_content );
	    foreach($blocks as $block){
		    if ( $block['blockName'] === $block_name ) {
		    	if(isset($block["attrs"]["data"][$field_name])){
                             $content = $block["attrs"]["data"][$field_name];
		    	}
		    }	    	
	    }  
	}
	return $content;
}

however it returns unformated values and as for repeater field it returns number of rows.

How can we get the contents of the rows ?
also how can we format the output as it was stated in backend for that field ?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the supplied get_field_from_block() function and its parse_blocks() call, reproducing the ACF Gutenberg repeater case on an archive page. Determine how repeater row contents and formatted field output should be retrieved, then verify that both are available consistently outside the editor.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, wordpress
Domain
backend, content
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.