Support

Account

Forum Replies Created

  • @hube2 – Thanks. My bad there on the logic — was a quick check. I’ve refactored and you are indeed correct: reset_rows() is the answer.

  • @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();
      }
    }
  • @hube2 – Correct.

    The title filter (called first) is using have_rows() and the content action (called second) is using have_rows() on the same post.

    I’ve also tried have_rows(‘field’,$post->ID) in both functions. The same behavior occurs — the first function works and the second one that uses have_rows() does not.

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