CPT Review Loop with ACF

The reviews on our homepage are saved as a Custom Post Type (reviews) with ACF fields to handle rating and reviewer details.


  • ★★★★★
    Excellent lowcode templating

    Quite a nifty and powerful plugin for lowcode templating 🙂 Saves a ton of development time.

  • ★★★★★
    I LOVE IT! <3


  • ★★★★★
    Excellent Plugin

    Loops & Logic is awesome! Makes it so easy to build out dynamic content and support has been amazing.

  • ★★★★★
    The plugin is great and the support is awesome

    The best support I’ve ever had! I’m not even kidding!

  • ★★★★★
    Just brilliant. Great support too.

    As a WordPresser who slings HTML + Tailwind CSS, this plugin has been an absolute godsend. I can do complex queries in the front end, and can go further than any ‘Posts Module/Block/Widget’ UI could ever hope for.

  • ★★★★★
    I’m SO glad I discovered Loops & Logic!!!

    Now I can finally create my own dynamic websites! The possibilities are endless! And if you get stuck; the support is fast, professional and very comprehensive!

    From now on I will use Loops & Logic in as many projects as possible so that all content is clear and flexible.

  • ★★★★★
    Amazing Tool that changes everything!

    I can’t imagine using WordPress without Loops & Logic. I’ve replaced cumbersome page builder sections with simple and powerful L&L templates that work perfectly with ACF and CPT. The team is brilliant and unbelievably helpful. Thanks!

 <ul class="grid-masonry">
    <Loop type=reviews orderby_field_number=rating order=desc>
      <li class="tt-item card {Field post_class}">
        <div class="content">
          <If field=rating>
            <div class="rating">
              <Switch check="{Field acf_radio=rating}">
                <When value="5" />★★★★★
                <When value="4" />★★★★☆
                <When value="3" />★★★☆☆
                <When value="2" />★★☆☆☆
                <When value="1" />★☆☆☆☆
          <div class="title"><Field title /></div>
          <div class="description"><Field content /></div>
        <div class="footer">
          <Set person_content>
            <If field=person_image>
              <span class="avatar"><img src="{Field acf_image=person_image field=url}" alt="{Field person_name}" /></span>
              <div class="name"><Field person_name /></div>
              <div class="role"><Field person_role /></div>
          <If field=person_website>
            <a class="author" href="{Field person_website}" target="_blank" rel="nofollow noopener">
              <Get person_content />
            <Else />
            <div class="author">
              <Get person_content />
  1. To open a CPT loop, use the Post Type Slug in the type attribute. You can sort the returned posts by a custom field with orderby_field or orderby_field_number
  2. To save a bit of time, you can use Switch/When tags for your logic instead of If/Else. This saves you from having to pass your field to each statement. This rating section could also be written as:
    <If check="{Field acf_radio=rating}" value=1>★☆☆☆☆<Else if check="{Field acf_radio=rating}" value=2 />★★☆☆☆ etc.
  3. Use Set and Get to save pieces of markup for use elsewhere. In this example it’s being used for the inner author content, so that it can be placed into alternate wrappers depending on whether there’s a website link available
  4. When using alternate wrappers, it’s usually best to approach things this way instead of wrapping the opening and closing tags each in their own if statement