Support

Account

Home Forums ACF PRO have_rows() Issue Reply To: have_rows() Issue

  • @hube2 – Thanks, but no go. have_rows() still returns FALSE in the second function.

    // Check for alternative title
    add_filter( 'genesis_post_title_text', 'bk_process_title' );
    function bk_process_title($title) {
      if(have_rows('flex_content')) {
        while(have_rows('flex_content')) {
          the_row();
          if(get_row_layout() == 'sales') {
            $acf_field = get_sub_field('title');
            return $acf_field ? $acf_field : $title;
          }
        }
        reset_rows();
      } else {
        return $title;
      }
    }
    // Check for alternative listing content
    remove_action( 'genesis_entry_content', 'genesis_do_post_content' );
    add_action( 'genesis_entry_content', 'bk_process_content', 11 );
    function bk_process_content() {
      if(have_rows('flex_content')) {
        while(have_rows('flex_content')) {
          the_row();
          if(get_row_layout() == 'sales') {
            $acf_field = get_sub_field('deck');
            if($acf_field) {
              echo $acf_field;
            } 
          }
        }
        reset_rows();
      } else {
        the_excerpt();
      }
    }