Home › Forums › General Issues › Getting fields directly from DB
Hi, New to ACF and have made a field group called customer_additional_info with a text field called customer_display_name. This works on the taxonomy Customer that I have created, and the fields are displayed and data entered is saved.
However, I have a shortcode that uses SQL to gather names and info about each Company and display it in a list. I am able to get all the standard info about the Company, but not the ADF fields.
function gci_list_members()
{
$members_list=”;
ob_start();
global $wpdb;
$members_list = $wpdb->get_results(
“SELECT * FROM wp_term_taxonomy as tx, wp_terms as tr, wp_termmeta as tm
WHERE tx.taxonomy = ‘companies’ AND
tr.term_id = tx.term_id AND
tm.term_id = tx.term_id AND
tm.meta_key = ‘membership_type’ AND
(tm.meta_value != ‘Draft’ AND tm.meta_value != ‘Inactive’) AND
(tm.meta_value = ‘Adopter Company’ OR tm.meta_value = ‘FULL Member Company’ OR
tm.meta_value = ‘Tools Member’)
ORDER BY name ASC”);
$terms = get_terms( array(
‘taxonomy’ => ‘companies’,
‘hide_empty’ => false
) );
for ($k=0; $k < count($members_list); $k++)
{
// get the member ID
$loop_member_id = $members_list[$k]->term_id;
// get the company_display_name
$company_display_name = get_field(‘company_display_name’);
// get the member type
$loop_member_type_value = $members_list[$k]->meta_value;
} // end for loop
I have removed the bulk of the HTLM in the php above, but basically, it loops through and displays the 30 companies but the $company_display_name ends up being blank.
How do I find this value?

$loop_member_id = $members_list[$k]->term_id;
// get the company_display_name
$company_display_name = get_field('company_display_name', 'term_'.$loop_member_id);
The topic ‘Getting fields directly from DB’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.