Home Forums Add-ons Repeater Field recent post acf repeater


recent post acf repeater

  • How can I display three recent project post on the home page of my site, I’m using the Custom Field Repeater.

    <?php if( have_rows('recent_project') ): ?>
    <div class="row-full-width mb">
    <?php while( have_rows('recent_project') ): the_row();
        // vars new project
        $project_image         = get_sub_field('project_image');
        $project_title         = get_sub_field('project_title');
        $project_link          = get_sub_field('project_link');
      <div class="col-sm-6 col-md-3 box row-no-padding scrollimation scale-in fade-in">
            <a>" target="_blank">
            <div class="figure">
                <?php echo $project_title; ?>
            <div class="overlay">
            <img />" alt="<?php echo $project_image['alt']; ?>" class="img-responsive scrollimation scale-in fade-in">
      <?php endwhile; ?>
    <?php endif; ?>
  • Hi @rthomas98

    I don’t understand the question. It seems you’ve answered it yourself with the code you posted?

    Or are you saying the code is not working?

  • Hey @jonathan

    The code above will display my portfolio on the portfolio page, but I would like to pull the latest 3 projects on the homepage.


  • Ah I see..

    you can provide the have_rows() function with a second parameter which is your portfolio pages ID.

    //if 2 is the ID of your portfolio page
    <?php if( have_rows('recent_project', 2) ): ?>
    <div class="row-full-width mb">
    <?php while( have_rows('recent_project', 2) ): the_row();

    inside the while loop you no longer need to provide the ID.. just use the fields as normal.

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

The topic ‘recent post acf repeater’ is closed to new replies.