【发布时间】:2020-12-29 17:08:51
【问题描述】:
最后一个字段是密码,正如我在图片中标记的那样
这是我如何尝试获取该字段的代码..
add_filter('posts_where', 'yanco_posts_where');
function yanco_posts_where( $where ) {
$where = str_replace( "meta_key = 'repeater_machines_password_repeater_$", "meta_key LIKE 'repeater_machines_%_password_repeater_%", $where );
return $where;
}
if(isset($_GET['password'])) {
$password = sanitize_text_field( $_GET['password'] );
$meta_query[] = array(
// 'key' => 'repeater_machines_$_password', // Format: repeater_field + _ + $ + _ + repeater_sub_field password_repeater
'key' => 'repeater_machines_$_country_password_repeater_$_password',
'value' => $password,
'compare' => '='
);
}
【问题讨论】:
-
你到底想做什么?您是否尝试根据 ACF Codex 获取字段,例如 support.advancedcustomfields.com/forums/topic/…
-
我只想让我的搜索字段正常工作。为此,我需要捕获中继器中的最后一个字段并将其放入 KEY 中。
-
问题是,我有转发器 > 字段 + 转发器 > 在这个转发器中我有一个文本字段,我需要捕获并放入 meta_query 中的 KEY 中。我真的很感谢你的回复!非常感谢,希望你能帮助我
-
正如您在该链接上看到的那样,您可以使用 count() 获取转发器的数量,并使用该值创建 if 状态以获取最后一个转发器中的文本字段值。
标签: php wordpress advanced-custom-fields