php 具有acf转发器子字段的facetwp布局构建器

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 具有acf转发器子字段的facetwp布局构建器相关的知识,希望对你有一定的参考价值。

<?php
/** 'author' is Unique name set in advanced tab of layout builder settings for the item,
 ** loop over the array returned from ACF to build a html string from the subfields and return to layout builder's
 ** facetwp_builder_item_value filter
 **/

add_filter( 'facetwp_builder_item_value', function( $value, $item ) {
	if ( 'author' == $item['settings']['name'] ) {
		$value = '';
		$authors = get_field( 'author' );
		if ( !empty( $authors ) ) {
			foreach ( $authors AS $author ) {
				$value .= $author['title'] . ' ' . $author['name'] . '<br />'; // create an html string formatted as needed to return
			}
		}
	}
	return $value;
}, 10, 2 );

以上是关于php 具有acf转发器子字段的facetwp布局构建器的主要内容,如果未能解决你的问题,请参考以下文章