Advanced Custom Fields
[resolved] Add Custom Fields to Sidebar? (3 posts)

  1. Treebeard
    Posted 4 years ago #

    I have some custom fields that are shown on the homepage and they're working perfectly. But when I try to include those in the sidebar so they appear on all pages in the site that use the Page template, the custom field areas are blank. Why is that? Am I missing something?

    All I'm doing is including the same exact code that I have on the homepage template, in the sidebar template, but nothing happens.

    Anyone know if this is a bug, if this is something that can't be done, or if I'm just doing this incorrectly?


  2. Harrison Ortega
    Posted 4 years ago #

    That's because the custom field is in the sidebar, outside the loop. That is, the custom field call does not know which page it is and so its blank.

    You can use a WP_query function to create another loop on the sidebar and just call the custom field:

    global $wp_query;
    $postid = $wp_query->post->ID;
    echo get_post_meta($postid, 'customField', true);
  3. elliotcondon
    Plugin Author

    Posted 4 years ago #

    Hi guys,

    If you use the get_field or the_field functions, ACF will do all this for you!


Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Advanced Custom Fields
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.