Note: apologies if this is a duplicate. When trying to edit my previous entry it seems to have been wiped out.
I’m new to ACF Fields and WordPress in general, and am having some difficulty wrapping my head around how to properly access a global variable that gets updated through through some of our custom functionality attached to the_content filter. Pairing things down for the purpose of testing, in the following example I would expect (incorrectly) that the global $counter variable in the format_value filter would reference the updated value as set by the_content. I’ve tried adjusting the priorities to no avail, amongst a number of approaches such as handling the counter through a singleton pattern.
Essentially what we’re attempting to accomplish is insert ads after a specific number of paragraphs. All is working fine using a number of class methods in our template to handle insertions on paragraphs in the_content. We have a counter in place to track the post-paragraph ad insertions, but I can’t access the counter to then follow with ad insertions on ACF content.
ACF does not call the hook the_content when formatting a wysiwig field. Instead it uses acf_the_content. Basically your first filter is never run for the wysiwyg acf field. You’d need to add your code for both hooks.
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users