Home Forums Front-end Issues ACF on home.php


ACF on home.php

  • I’ve read the article about using get_option('page_for_posts') and never had any problems, but for some reason, it’s not working today and I’m baffled!

    Below is everything I’ve tried and nothing pulls through despite fields being populated and everything looking correct…

    <h1>Here - <?php the_sub_field('show_latest', get_option('page_for_posts') ) ?></h1>
    <?php if ( get_sub_field( 'show_latest', get_option('page_for_posts') ) == 'Latest Event' ): ?>
        Latest Event
    <?php elseif ( get_sub_field( 'show_latest', get_option('page_for_posts') ) == 'Latest News' ): ?>
        Latest News
    <?php else: ?>
    <?php endif; ?>
    <?php the_field( 'banner_heading', get_option('page_for_posts') ); ?>
  • If you are getting sub fields then you need a loop, the loop will need the post ID but the sub fields do not.

    if (have_rows('repeater_field_name', $post_id)) {
      while (have_rows('repeater_field_name', $post_id)) {
  • Hi John,

    That didn’t work sadly…

    I have the home.php page and want a banner, in the back-end I have fields created for banner_heading etc. and just want them to appear.

    However, it doesn’t despite trying different techniques including the above.

  • Give me more information about the field.

    Field type

    Field settings

    field group location rules

  • These are the fields in ACF (flex);

    and these are how they look in the blogs page;

  • I’m a little confused so I’m guessing.

    You are trying to show this one flex layout on a page other than the page where it has been added?

  • Sorry didn’t mean to confuse.

    I’m trying to show this flex layout on home.php which is blogs page, showing all my blogs.

    Each page has a banner (which works fine on other pages) but doesn’t on the blogs page.

  • I think I may understand your issue.

    I will need to see some code from home.php, I don’t need all of it. What I need is to understand where in relation to “The Loop” you are trying to show the for the flex field.

  • Hi John,

    It seems you were right near the start and my brain wasn’t connecting the dots.

    This code cracked it;

        if( have_rows('content') ):
        while ( have_rows('content') ) : the_row();

    Thanks for the continued help 🙂

Viewing 9 posts - 1 through 9 (of 9 total)

The topic ‘ACF on home.php’ is closed to new replies.