Forums › Forums › Search & Filter Pro › Can I filter fields in custom table created outside WP core oltables?
Tagged: V3
- This topic has 5 replies, 3 voices, and was last updated 1 year, 3 months ago by Anonymous.
-
Anonymous(Private) January 6, 2020 at 11:03 am #230230
Hello,
I am using ACF Custom Database Tables plugin that creates custom tables for ACF custom meta data. ACF Custom Database Tables uses ACF’s core API functions – get_field() and update_field() – to store/retrieve data from custom tables.
The fields for the Custom Post Type are created as usual with ACF, but then the plugin saves the data in a custom table, outside the normal WP post meta table.
I was wondering if I can use the SF Pro plugin for searching and filtering this custom table, maybe by altering the WP_Query?
The custom fields do not appear in the Post Meta table at all, and also not in the SF post meta search field.Regards!
Ross Moderator(Private) January 6, 2020 at 11:15 am #230237Hi Alex
Hmmm, I’m not sure if this will work.
When we build the cache, we will use
get_post_meta
to retrieve the ACF values for the posts we cache.Do those plugins, intercept
get_post_meta
and perform the lookups on their own tables? Or do you need to use specific ACF functions to retrieve the data associated with a post?Thanks
Ross Moderator(Private) January 6, 2020 at 1:40 pm #230246Hi Alex
Ok so the issue I think is, when we build the cache of all the posts (a long query capturing all possible posts), we check
meta_key
and useget_post_meta
, to store a copy of the value in our tables.Editing the actual query won’t be possible, because we’ve set
suppress_filters
totrue
on that particular query so there is no way of intercepting it.In addition, that doesn’t change how we then process the results, as we’re calling
get_post_meta
using the keys from the search form…In the next major version, we will be allowing indexing of custom tables, and custom processing filters on our caching process to change how certain values are handled / stored (so you could replace
get_post_meta
.Of course this is not a solution for you right now, but I did think of one possible work around:
https://developer.wordpress.org/reference/hooks/get_meta_type_metadata/
https://wordpress.stackexchange.com/questions/121679/how-to-hook-a-filter-to-catch-get-post-meta-when-alternate-a-custom-field-outputI think with this you can intercept a call to a specific meta key, and return a different value, basically using the the ACF API to retrieve the correct value, so our call to
get_post_meta
would get the correct value in the end and store in our tables (this is of course completely untested)…Let me know how you get on.
Thanks
Anonymous(Private) September 6, 2023 at 2:03 pm #276857Hi,
I have a generally similar configuration. For my part, my CPTs are saved in different tables to optimize queries as much as possible because I have a lot of data.
You were talking about a major development allowing custom tables to be intercepted in January 2020. Is there anything new in this regard?
Thanks in advance
-
AuthorPosts