Home › Forums › General Issues › Retrieve Custom Field in Sidebar & Footer › Reply To: Retrieve Custom Field in Sidebar & Footer
Hi
In order to display custom field values in the sidebar and the footer.
You will need to provide a second parameter of the post id to the the_field/get_field function.
For example
$post_id = null; // current post
$post_id = 1; // post 1
$post_id = "option"; // options page
$post_id = "options"; // same as above
$post_id = "category_2"; // target a specific category
$post_id = "event_3"; // target a specific taxonomy (this tax is called "event")
$post_id = "user_1"; // target a specific user (user id = 1)
the_field( "text_field", $post_id );
https://www.advancedcustomfields.com/resources/the_field/
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.