Add a php 'include' to a block?

I have added the following code to my child theme’s functions.php file, but it doesn’t work:

add_filter('hivepress/v1/templates/listing_view_page', function($template){
    return hivepress()->helper->merge_trees($template,[
        'blocks' => [
            'page_content' => [
                'blocks' => [
                    'listing_description_calc' => [
                        'type' => 'content',
                        'content' => include 'listing-calcs.php',
                        '_order' => 70,

The snippet above returns plain text and html fine, but I would like to include another php file.
Is this possible?

Bump, any assistance with this would be greatly appreciated!

Sorry for the late reply.

Please try this solution PHP include w/o echo - Stack Overflow This way you can assign file contents to a variable first, and then use it in the content block.

@ihor What am I doing wrong here? The code below doesn’t output my simple text, let alone an included file.
variable not output

The output variable is set outside the function scope, so it can’t access it, please try moving it inside the function. You can also enable WP_DEBUG, in this case there would be the “Undefined variable” error displayed.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.