Support

Account

Home Forums General Issues Move ACF field to separate db table Reply To: Move ACF field to separate db table

  • I can’t give you any advice on using a different table, but since you mention that you don’t know how WP works I will give you some insight into it.

    When you are in “The Loop”

    
    while (have_posts()) {
      the_post();
    }
    

    part of what WP does automatically is that it gets all of the post meta values for the current post in a single query, or it should, and stores all of the values in the meta cache for the post. Queries for individual post meta values should not be made in this case.

    When you are getting values for other posts when not in a loop and WP is not automatically setting up the post and getting the meta values then it is possible that WP will do a query for each meta value. However, there is a solution for this.

    
    get_post_meta($post_id);
    

    When you call get_post_meta() with a post ID and no meta key specified then WP gets all of the post meta values for the post in a single query and stores the values in the cache so that later it will not, or should not, perform individual queries for each meta value.

    If you still want to go with custom tables then you might want to look at this https://www.awesomeacf.com/storing-acf-data-custom-database-tables/