Roots Discourse

What to use on Controllers to get ACF from all 'page' post types?

Basically, I am trying to call a get_field that is supposed to work on all “pages” post type. It’s only a True/False ACF. I looked at the WordPress hierarchy and tried Page.php

<?php

namespace App\Controllers;

use Sober\Controller\Controller;

class Page extends Controller

{
    public function pageSettings()
    {

        return (object) array(
            'force_container' => get_field('force_container')
        );

    }

}

Also tried SinglePage.php but no luck.

I tried @debug but I didn’t see the function there.

Does it work if you extend your specific page controllers from your Page class?

I do something similar using Timber where I have generic methods that are supposed to be available on all pages.

No reason that shouldn’t work. It should be available in the blade template as $page_settings->force_container