Support

Account

Home Forums Add-ons Options Page Is it possible to set up Option fields per "page"

Helping

Is it possible to set up Option fields per "page"

  • I am a very happy ACF PRO customer and I have the following need:

    I need to be able to determine in each of my posts / pages certain amount of options, such as Theme (dark / light) which will change the background for the page / post in question depending on what the editor chooses. This is not per category, its per POST or PAGE.

    The problem I have is that if I determine such option using a Select field, for example, I am limited because: I first need to load the body in certain color, then the post will load, then I will get the value from that select ACF and only then I will be able to re-style the body again. So far I know, my select field value can’t be accessed globaly and I can’t access it outside the loop, so I can’t check the value of a page right when I am styling the body. The problem is that if I do it as I mentioned, it simply this looks ugly. The Option field looks closer to what I need because I can access it globaly, but it’s defining a global setting for the entire page, and not for every page in question.

    So my question: How can I set up options for specific posts and pages that I can access globaly?

  • I know that this is an old question and you may not need help with it at this point, but someone else may be looking for similar information.

    What you want to accomplish is possible to do before you get to the content. In your header.php files you can do something like:

    
    $queried_object = get_queried_object();
    if (isset($queried_object->ID)) {
        $post_id = $queried_object->ID;
        $field_value = get_field('my_field', $post_id);
    }
    
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Is it possible to set up Option fields per "page"’ is closed to new replies.