Home › Forums › Front-end Issues › Problem with repeated objects assigned to posts › Reply To: Problem with repeated objects assigned to posts
Looks like this
<?php get_header(); ?>
<div id="innerwrapper" class="page">
<div class="container">
<div class="row">
<div id="lewaKolumna" class="col-xs-3 col-sm-3 col-md-3 hidden-xs hidden-sm">
<div class="sideModule">
<?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar(17) ) : else : ?>
<?php endif; ?>
</div>
</div>
<div id="prawaKolumna" role="main" class="col-xs-12 col-sm-9 col-md-9">
<div class="catHeader">
<div id="breadcrumbs">
<?php if(function_exists('bcn_display'))
{
bcn_display();
}?>
</div>
<div class="headerImg">
<?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar(14) ) : else : ?>
<?php endif; ?>
</div>
<div class="headerCatDesc">
<?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar(15) ) : else : ?>
<?php endif; ?>
</div>
</div>
<div id="podstrona">
<div class="contentBodyWrapper kanalyPremium">
<?php
/* Główna pętla */
$args = array(
'post_type' => 'kanaly_premium',
'posts_per_page' => -1,
'orderby' => 'date',
'order' => 'DESC',
);
$fullnewsloop = new WP_Query($args);
if($fullnewsloop->have_posts()):
while($fullnewsloop->have_posts()): $fullnewsloop->the_post(); ?>
<div class="pakietBoxLista row">
<div class="col-xs-12 premiumTitle">
<h2><?php echo the_title(); ?></h2>
</div>
<div class="col-xs-12 col-md-3">
<?php if(get_field('okladka_pakietu_premium')): ?>
<?php $okladkaPremium = get_field('okladka_pakietu_premium'); ?>
<div class="headerImg">
<img src="<?php echo $okladkaPremium['sizes']['medium'] ?>" />
</div>
<?php endif; ?>
</div>
<div class="col-xs-12 col-md-9">
<?php if( get_field('krotki_opis_pakietu_premium')): ?>
<?php the_field('krotki_opis_pakietu_premium'); ?>
<?php endif; ?>
<ul id="pakietBoxLista">
<?php // check current row layout ?>
<?php if( have_rows('programy_lista') ): ?>
<?php while ( have_rows('programy_lista') ) : the_row(); ?>
<?php
$post_objects = get_sub_field('kanal');
if( $post_objects ): ?>
<?php foreach( $post_objects as $post): // variable must be called $post (IMPORTANT) ?>
<?php setup_postdata($post); ?>
<li class="kanalTelwizyjny">
<section class="kanalWrapper">
<?php //Elementy kanału ?>
<?php if(get_field('klasa_obrazka_kanalu', $post->ID)): ?>
<div class="sprite sprite-premium sprite-premium-<?php the_field('klasa_obrazka_kanalu', $post->ID); ?>"></div>
<?php else: ?>
<div class="sprite sprite-premium sprite-premium-<?php echo $post->post_name; ?>"></div>
<?php endif; ?>
<div class="kanalWrapperInner row row-eq-height">
<div class="col-md-3 col-sm-4 imgPrevBlock">
<?php if( get_field('pakiety_dostepne_w', $post->ID)): ?>
<div class="dostepnyW"><p>Dostępne w pakiecie:</p><?php the_field('pakiety_dostepne_w', $post->ID); ?></div>
<?php endif; ?>
<?php if( get_field('dostepny_na_kanale', $post->ID)): ?>
<div class="dostepnyNa"><p>Dostępny na kanale:</p><?php the_field('dostepny_na_kanale', $post->ID); ?></div>
<?php endif; ?>
<?php if( get_field('kategoria_kanalu', $post->ID)): ?>
<div class="kategoriaKanalu"><p>Kategoria:</p><?php the_field('kategoria_kanalu', $post->ID); ?></div>
<?php endif; ?>
<?php if( get_field('jakosc', $post->ID) == "Jakość SD" ): ?>
<div class="wyborJakosci"><p><?php echo get_field('jakosc', $post->ID); ?></p></div>
<?php else: ?>
<div class="wyborJakosci jakoscHD"><p><?php echo get_field('jakosc', $post->ID); ?></p></div>
<?php endif; ?>
</div>
<div class="col-md-9 col-sm-8 shortDescBlock">
<h3 class="catItemTitle">
<?php the_title(); ?>
</h3>
<div class="catItemIntroText listaPremium">
<?php the_content(); ?>
</div>
</div>
</div>
</section>
</li>
<?php endforeach; ?>
<?php // wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly ?>
<?php endif; ?>
<?php endwhile; ?>
<?php endif; ?>
</ul>
</div>
<div class="col-xs-12 col-md-12 readMore">
<a class="btn pull-right" title="więcej" href="<?php echo get_permalink( $post->ID ); ?>">więcej</a>
</div>
</div>
<?php
endwhile;
endif;
?>
</div>
</div>
</div>
</div>
</div>
</div>
<?php get_footer(); ?>
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.