Support

Account

Home Forums ACF PRO have_rows('rows') not working in home.php

Helping

have_rows('rows') not working in home.php

  • hi Eliot,
    I have a bit of code that works on every other page except the default blog listing page which is home.php. I always get “no rows loaded” when there are rows assigned to in pages > Posts Page.

    My code is as follows:

    if( have_rows(‘rows’) ){
    while ( have_rows(‘rows’) ){
    the_row();
    // load data
    }
    }else{
    echo “no rows loaded”
    }

    This seams to work on every page, from home page to custom templates. It just will not seam to work on the home.php page though.

    Any help would be greatly appreciated.

    thanking you, Joe

  • I’m assuming that you have the settings in WP set to show a static page for the home page and the blog index. The problem is that nothing on this page is going to have an effect on the blog index.

    What you are going to have to do to get the values from that page is something like this.

    
    $post_id = get_option('page_for_posts');
    if (have_rows('rows', $post_id)) {
      while (have_rows('rows', $post_id)) {
        the_row();
        // load data
      }
    } else {
      echo “no rows loaded”
    }
    
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘have_rows('rows') not working in home.php’ is closed to new replies.