Support

Account

Home Forums General Issues How to display data from other tables?

Solving

How to display data from other tables?

  • Hi

    I want to display other fields from.other tables. Woocommerce has a product page and i have added some custom fields. So far so good. I juts dont know how to display data from other tables

    Is this possible? How please

  • hi

    i got this to work by copying the meta key from postmeta and adding it to acf

    unfortunately its disabling the original field.

    example

    cost_price = found in the same table but different plugin. So i just copied the meta key cost_price added it to acf rename it to acf_cost_price and it displays all data associated with cost_price. Unfortunately it disables the original cost_price field. i can no longer edit/save it. The only way to edit or change the value is directly on acf_cost_price

    Hope any one shines some light on how to accomplish this.

    thanks

  • If you’ve used a different meta key than the original plugin, your examples “acf_cost_price” instead of “cost_price” then this should have no affect on the original plugin field.

    The only thing that can cause this is using the same meta key, the ACF field name. When using the same meta key then only editing only one of the fields will work and this will be the field that is saved last this value will overwrite whatever value is saved first.

  • Thanks john

    Do you have any documentation how to use a different meta key and retrive/edit the value of the original.plugin.

    How can acf_cost_price get the value from cost_price? Edit?

    Thanks so much

  • There are several ways that you can do this.

    How I would do this is that I would create an acf/load_value filter:

    
    add_filter('acf/load_value/name=YOUR_FIELD_NAME', 'YOUR_FUNCTION_NAME', 20, 3);
    function YOUR_FUNCTION_NAME($value, $post_id, $field) {
      $value = get_post_meta($post_id, 'OTHER_FIELD_NAME', true);
      return $value;
    }
    
  • Thanks again john

    Forgive me for my.ignorance.

    Will this go to the functions.php?

    Also

    add_filter(‘acf/load_value/name=YOUR_FIELD_NAME’, //is this acf field?

    ‘YOUR_FUNCTION_NAME’, 20, 3);
    function YOUR_FUNCTION_NAME($value, $post_id, $field)// is this still acf field
    {
    $value = get_post_meta($post_id, ‘OTHER_FIELD_NAME’, true);//data here is the other plugin?
    return $value;

    Again thanks for your patience

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.