Support

Account

Home Forums General Issues Getting fields directly from DB

Unread

Getting fields directly from DB

    • gagcon

    • October 9, 2019 at 6:18 am

    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?

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.