V
V
Vladimir Kulikov2020-05-25 22:50:34
WordPress
Vladimir Kulikov, 2020-05-25 22:50:34

How to find the post id by acf value?

Hello, for example, there is an acf field "name" in the records. All records are different.

How to get the id of the entry, or the object of the entry, by the value of "name"?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
WP Panda, 2020-05-25
@it_proger29

https://gist.github.com/qstudio/8bc172f60f65aa6f000f
or so

global $wpdb;
$results = $wpdb->get_results( "SELECT post_id  from $wpdb->postmeta WHERE meta_key = 'my_key' AND meta_value = 'my_value'", ARRAY_A );

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question