Get ACF Field(s) From Specific Page - Place In Footer

Hello, I’m trying to place some fields in my footer, but they are located on my Home page. For example, business hours, some fields that I’ve setup in the Home page, but I feel they should also be in the footer. I’d highly prefer not to hard-code these values in.

I’ve tried using the number from post= /wp-admin/post.php?post=7&action=editthen doing the following:

{{ the_field('hours-o-mo', 7) }}

and also

	the_field('hours-o-mo', 7) 

Any suggestions? I’m sure there must be an easy way to do this. Thanks for any pointers!

What is the error you’re running into?

No error, just no output. I should be seeing the data from the field, if it worked. It’s maybe worth noting that the fields are on a page, not a post, even though the url says post. Sorry, I’m new to WP dev. >.<

This seems like more of a general WordPress/ACF issue than an issue with the Roots stack. You might look into get_option('page_on_front') if you’ve assigned a specific page to be your front page.

In Sage, you would probably want to be doing this logic (getting a value from an ACF field) at the controller level, rather than in the template.

Great, thanks for the help @alwaysblank! You’re right, probably a more general question. I’ll check in to getting and passing via controller.

Hi @darthink,

Have a look in to Laravel Stacks

On your homepage template you would push the hours and on the footer template/partial you would display the pushed data with stack.


    {{ the_field('hours-o-mo', 7) }}



This would push information/data from homepage to the footer, however not for other pages, you would likely want to create some ACF fields as options which is globally available, not specific for homepage only for example:

Don’t forget if you’re grabbing data from ACF options then be sure to use the , 'option' in addition to the field name: the_field('field_name', 'option')

1 Like

Hi @JordanC26!

Thank you very much for this solution / idea! I tested and can confirm, it works!

The only unfortunate part is not persisting through pages. I think what I might have to do is activate the ACF options like you suggested.

Thanks again!

This topic was automatically closed after 42 days. New replies are no longer allowed.