text ACF文本字段:标签+数据

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了text ACF文本字段:标签+数据相关的知识,希望对你有一定的参考价值。

// Important: give your labels human readable names!

// Book store details
$book_shop_details = array(
	'book_store_name',
	'book_store_link',
	'book_store_logo',
	'book_title'
);

// Is there data in one of the fields?
$has_meta = false; //init
foreach( $book_shop_details as $detail ) {
	if( get_field( $detail ) ) {
		$has_meta = true;
		continue; // Just need one meta field filled to create the div.
	}
}

if( $has_meta ) {
	echo '<div class="single-book">';
	foreach( $book_shop_details as $detail ) {
		$shop_detail = get_field( $detail );
		if( $shop_detail ) {
			$obj = get_field_object( $detail );
			$label = $obj['label']; //field label
			echo $label . ': '. $shop_detail;
		}
	}
	echo '</div>';
}

以上是关于text ACF文本字段:标签+数据的主要内容,如果未能解决你的问题,请参考以下文章