Home Forums General Issues Good idea to use the_content filter to add ACF content?


Good idea to use the_content filter to add ACF content?

  • Just curious if anyone does this, or recommends it or not…

    We are now using repeaters and flexible content to add onto a page all the different types of content blocks the page may be made up of. Slideshow, Newsletter Signup, Grid based text, videos etc.

    At the moment we hard code the ACF fields code into our theme templates. We use template-parts to include them, but nevertheless we still have to include that in the theme file.

    I was wondering if anyone thinks using the the_content filter to add the ACF fields after that would be a good idea. So add_filter( ‘the_content’, my_acf_fields);

    The benefit would be if we build a new site and wanted to reuse all the ACF fields, we wouldn’t need to worry about hard coding ACF, they will all get added after the content.

    We could for example switch to TwentySeventeen and all the ACF content will still be output. There wouldn’t be any styling, but then I am also thinking of including the CSS styles within the ACF functions anyway, so actually they would.

    Any feedback on this?


  • Hi @infoamitywebsolutions-co-uk

    ACF actually makes use of a similar filter to fetch the ACF data this is the acf_the_content filter.

    This controls the output from the ACF WYSIWYG field and you can use the filter to format the value.

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

The topic ‘Good idea to use the_content filter to add ACF content?’ is closed to new replies.