Support

Account

Home Forums Front-end Issues custom field applied to "page" not seen in archive-page Reply To: custom field applied to "page" not seen in archive-page

  • Outside of “The Loop” which is where the header is, you need to tell ACF what $post_id you want to use get_field('field_name', $page_id); $page_id can take many forms form an actual post id to a user to a term. This is covered on https://www.advancedcustomfields.com/resources/get_field/ in the section Get a value from different objects.

    How you get the post ID for the current page depends on what you’re trying to get. For example an archive page is generally associated with a term

    
    $post_id = 0;
    $queried_object = get_queried_object();
    if (isset($queried_ojbect->term_id)) {
      $post_id = 'term_'.$term_id;
    }
    

    and this will only work if you have a custom field associated with the term in question.

    For most “archive” pages, there isn’t anywhere to put a custom field. Archive pages outside of terms do not have an admin page, so there isn’t any way to add a field to a specific archive. In this case the best option is an options page that is associated with a specific post type.