简体   繁体   English

根据另一个转发器值获取高级自定义字段转发器字段值

[英]Get advanced custom fields repeater field value based off of another repeater value

I have a repeater field on a page, in that field i have a post object field and a few text fields. 我在页面上有一个转发器字段,在该字段中,我有一个发布对象字段和一些文本字段。 The post object field just gets the ID of whatever post you set. 发布对象字段仅获取您设置的任何发布的ID。

When i am a single post i want to run a database query that uses the current post ID to find the matching sub field, then get another sub field in that same repeater field. 当我是单个帖子时,我想运行一个数据库查询,该查询使用当前的帖子ID查找匹配的子字段,然后在同一转发器字段中获取另一个子字段。

Can anyone help with this? 有人能帮忙吗?

This is what i have so far which is not want i need but its the closes it have been able to get 这是我到目前为止所不想要的,但是它已经能够实现的关闭

$games_id_array = $wpdb->get_results(
$wpdb->prepare( 
    "
        SELECT * 
        FROM wppp_postmeta
        WHERE meta_key LIKE %s
        AND meta_value LIKE %s
    ",
    'contributing_game_creators_%_game_creator_roles',
    '%'.$search_value.'%'
)
);

That won't work, I've lost a few hours to it. 那行不通,我已经花了几个小时了。 The ACF repeater fields get a new id that doesn't correspond to the parent-post id (except for the first one). ACF转发器字段会获得一个与父帖子ID不对应的新ID(第一个ID除外)。 To make this even more confusing: If you delete a repeater field, it can stay in the database; 使这一点更加令人困惑:如果删除一个转发器字段,它可以保留在数据库中; so any queries will return all of the repeater-field data, old & new. 因此,任何查询都将返回所有旧的和新的转发器字段数据。

The best workaround I've found for this is to loop the repeater field silently and push the data to a multidimensional array. 为此,我发现最好的解决方法是静默循环转发器字段并将数据推送到多维数组。 Then loop over that array again to produce the output. 然后再次遍历该数组以产生输出。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM