wordpress loop broken using ACF

Im building a website with WordPress and Advanced Custom Fields(ACF). In my loop, I want to check for a category and then get into the ACF rows. But somehow the loops seems broken. For clarity, i’m now only outputting the titles. The titles in my wp admin are: one, two, three, four, five, interview.

This is my code:

Read More
<?php
if( have_posts() ):
  while( have_posts() ): the_post();

    $category = get_the_category( $post->ID );
    $category_id = $category[0]->cat_ID;
    $category_slug = $category[0]->slug;

    // Content redirects for 'sessions'
    if( $category_slug == 'sessions' ){
      if( have_rows('content') ):
        while( have_rows('content') ): the_row();

          echo the_title();

        endwhile;
      endif;
    }

    // Content redirects for 'sessions'
    elseif( $category_slug == 'interviews' ){

      echo the_title();

    }

  endwhile;
endif; ?>

This is the output:
“FiveFiveFiveFiveFiveFourFourFourFourFourThreeThreeThreeThreeOneOneOneOneOneInterview”

SCREENSHOT:
enter image description here

without the ACF loop, the output is perfect: one of each. But I can’t seem to figure out what’s wrong with it.

I’m really stuck on this, hope someone can help, thanks!

Related posts

Leave a Reply