text ACF画廊的强大表格

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了text ACF画廊的强大表格相关的知识,希望对你有一定的参考价值。

//Update ACF field to see gallery on the front without having to update the cpt in the admin
add_action('frm_after_create_entry', 'update_my_acf_field', 30, 2);

function update_my_acf_field($entry_id, $form_id){
		if ($form_id == 7) { //replace 7 with the id of the form
			
			$latest_cpt = get_posts("post_type=portfolio&numberposts=1");
			$latest_cpt_id =  $latest_cpt[0]->ID;
			
			$acf_field_name = '_galerie'; // the acf gallery field name
			$automated_prefixed_key = '_'.$acf_field_name;
			
			$acf_field_id = 'field_5ba213a60d369'; // the acf gallery field id. See Browser Inspector in admin to get it
		
			//update_field('_name_of_you_gallery_field', 'field_value_checked_in_database', $latest_cpt_id);
			update_field($acf_field_name, $acf_field_id, $latest_cpt_id);
			//By default, a second entry with the same key as the name of the gallery field, prefixed with an underscore, is created. We delete it.
			delete_post_meta($latest_cpt_id, $automated_prefixed_key);			
		}
}

以上是关于text ACF画廊的强大表格的主要内容,如果未能解决你的问题,请参考以下文章

php ACF画廊

html acf画廊网格

html acf画廊网格

text ACF表格前端短代码插件

如何从 wordpress 中的帖子页面 id 获取 acf 的画廊图片 url

php 来自ACF Gallery的Slick Slider带缩略图导航(链接画廊)