Home Forums Add-ons Flexible Content Field Can I run PHP in a flexible content field?


Can I run PHP in a flexible content field?

  • Just learning about this plugin and have seen it used in a site but have a quick question.

    Can I insert straight PHP code into a block and have it executed. My goal is to query and display data located in an external table in the WP database in a page currently constructed with ACF Flexible content.

    Thanks in advance,

  • Hi @pringletech

    Yes, you can add PHP code to a textarea field (with a flexible content layout), and then execute it with the eval function like so:

    $code = get_field('code');
    eval( $code );

    Please note the above uses get_field, if you wish to use this within a flexible content field, you will need to use get_sub_field instead. Please refer to the dos for more on this.


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

The topic ‘Can I run PHP in a flexible content field?’ is closed to new replies.