Support

Search results for ""

Sorry, no results found. Perhaps you would like to search the documentation?
All Topics
Morgan Payne

ACF Fields don’t work with Post Template Rules

On a number of sites I use admincolumns on I’ve been having trouble getting ACF to show up when setting up coloumns.

After a lengthy amount of time I’ve come to the conclusion it has something to do with the fact we have our ACF to show for certain post templates.

https://prnt.sc/SmzRqG9OLzN-

If I remove these rules then all the ACF show up when I’m setting up coloumns, but as soon as i add them back, they disappear.

This is what it looks like when I have the post template rules on.. https://prnt.sc/LcUreCTC3TI0

and this is what it looks like when I remove the post template rules in ACF.. https://prnt.sc/OIIGM-nCqV2k

As you can see a lot more fields show up.

This has been an ongoing issue for many months and I’ve finally worked out that it has to do with the post template. Any help or advice would be appreciated.

1 month, 3 weeks ago
Stefan
Developer

The post template location rule does not say anything global about the post type where it should show.
Maybe that is exactly what you want, but you could alter the location rule and specifically set a rule to show it on one or more post types, so that our plugin knows that the fields are available for a specific post type overview.

Another solution is to use our hooks to make the fields available for a specific post type or for all post types. The snippet in your case should look like this.

add_action( 'acp/acf/before_get_field_options', function ( AC\ListScreen $list_screen ) {
	if( $list_screen instanceof AC\ListScreen\Post){
		add_filter( 'acf/location/rule_match/post_template', '__return_true', 16 );
	}
} );

add_action( 'acp/acf/after_get_field_options', function ( AC\ListScreen $list_screen ) {
	if( $list_screen instanceof AC\ListScreen\Post){
		remove_filter( 'acf/location/rule_match/post_template', '__return_true', 16 );
	}
} );
1 month, 3 weeks ago
Morgan Payne

Appreciate your help, tried the second solution and it works well.

1 month, 3 weeks ago
Stefan
Developer

I’m glad the solution works.
I’ll mark this topic as closed.

1 month, 3 weeks ago

You must be logged in to reply to this topic.