• Resolved zebedeeee

    (@zebedeeee)


    I am using AJAX Load More plugin to load more posts on my website. It’s working great. I need to do something a little different for the returned posts.

    I have an ACF radio button for each post to select if the post is Portrait or Landscape for example. Then in my loop I add a class to the post based on this selection. Which works well for the effect I need. However, I can’t replicate this for the repeater template. Is there any way I can do this?

    Here is my simple if/else statement.

    if (get_field('landscape_or_portrait') == 'Portrait') {
      $gridsetting = 'news-post-third';
    } else {
      $gridsetting = 'news-post-two-thirds';
    }
    • This topic was modified 8 years, 2 months ago by zebedeeee.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Darren Cooney

    (@dcooney)

    HI zebedeeee,
    Is the issue the get_field is not working?

    Try this:

    global $post;
    if (get_field('landscape_or_portrait', $post->ID) == 'Portrait') {
      $gridsetting = 'news-post-third';
    } else {
      $gridsetting = 'news-post-two-thirds';
    }
    Thread Starter zebedeeee

    (@zebedeeee)

    Amazing! Thank you. It worked. Why didn’t I think of that.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘ACF if else statements and repeater template’ is closed to new replies.