Created
May 24, 2018 16:34
-
-
Save guilhermealveslopes/72e612e09bd974210d764a5dcde67533 to your computer and use it in GitHub Desktop.
Get Post Object from ACF Repeater Field
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php $contador = 0; if( have_rows('produtos_relacionados') ): ?> | |
<?php while ( have_rows('produtos_relacionados') ) : the_row(); ?> | |
<?php $post_object = get_sub_field('produtos'); ?> | |
<?php if( $post_object ): ?> | |
<?php $post = $post_object; setup_postdata( $post ); ?> | |
<?php if( $contador <= 4 ): $contador++; ?> | |
<div class="item"> | |
<?php | |
if (has_post_thumbnail( $post->ID ) ){?> | |
<div class="img" style="background:url('<?php echo the_post_thumbnail_url('madium-large') ?>')"></div> | |
<?php | |
} | |
else{ ?> | |
<div class="img" style="background:url('<?php echo get_template_directory_uri() .'/images/sem-imagem.jpg' ?>')"></div> | |
<?php } | |
?> | |
<h2><a href="<?php the_permalink()?>"><?php the_title() ?></a></h2> | |
<p class="descricao"> | |
<?php echo excerpt(10) ?> | |
</p> | |
<a class="link" href="<?php the_permalink() ?>">Comprar</a> | |
</div> | |
<?php endif; ?> | |
<?php wp_reset_postdata(); ?> | |
<?php endif; ?> | |
<?php endwhile; ?> | |
<?php endif; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment