Forums › Forums › Search & Filter Pro › Duplicate post_meta when creating posts using frontend forms
- This topic has 11 replies, 2 voices, and was last updated 4 years ago by Trevor.
-
Anonymous(Private) November 30, 2020 at 3:48 pm #268221
Hi guys,
I’ve been using the plugin over the past couple of days for a simple business directory site I’ve built.
I’ve added the functionality of creating new CPT posts from the frontend using acf_form, and have also tried doing this using a form plugin that has a ‘Submit post’ feature.
I have one ACF field in my CPT that is a True/False checkbox, and in my S&F settings I have this as a post_meta object that will allow the user to show filter posts that have this value set to true. It’s to show which businesses offer a discount.
I’ve found that when new posts are created from the frontend and this field is empty (or not included in the form) it generates a duplicate post_meta checkbox in the S&F search form. This displays posts that have been created in the frontend and where the checkbox field has not been ticked.
You can view this here: https://wordpress-484512-1590491.cloudwaysapps.com/businesses/
Do you have any idea what I can do to prevent this?
Anonymous(Private) November 30, 2020 at 4:03 pm #268233Thanks Trevor. Am I right in thinking that the cache gets rebuilt when new posts are published? I am currently using the ACF frontend form to create draft posts, so am publishing them manually. Also, I rebuilding the cache manually does not seem to have removed the duplicate post_meta checkbox.
Trevor(Private) November 30, 2020 at 4:09 pm #268237When a Post is created or edited, and the Update button is pressed, WordPress triggers a hook/function (
save_post()
I think) that our plugin sees and updates the cache for just that post, not all posts. Some import tools do not trigger that function, hence the problem. Other search tools have similar issues, such as Relevanssi, which needs a similar action to update its cache.Anonymous(Private) November 30, 2020 at 4:19 pm #268250That’s the thing, this doesn’t resolve the issue. Neither editing and updating or rebuilding the cache removes the duplicate post_meta checkbox. When I check the checkbox field in the post, the duplicate disappears, when I uncheck it, the duplicate reappears…
Anonymous(Private) November 30, 2020 at 5:05 pm #268273Just following up again (sorry for bombarding) and I think the plugin is doing what it’s meant to do, which is display options to either show posts where the value is TRUE and where it is FALSE, but I confused myself regarding ‘duplicates’ because I added an :after pseudo element to display the label I wanted attached to the TRUE field. I guess I’ll just have to hide the FALSE checkbox with CSS? Thanks for your help.
-
AuthorPosts