Co drugi post pobiera złą miniature
-
Witam,
Ogólnie posiadam następujący kod podstrony:<?php if ( wp_get_attachment_url( get_post_thumbnail_id($post->ID) ) ) { $PostThumbnail = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); } else { $PostThumbnail = 'http://placehold.it/1920x500'; } ?> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <header style="background: url( <?php echo $PostThumbnail; ?> );"> <div class="container"> <div class="page-title"> <h1> <span><?php the_title(); ?></span> </h1> </div><!-- /.page-title --> </div><!-- /.container --> </header> <?php endwhile; ?> <?php endif; ?> <?php $countOffers = wp_count_posts( 'offer' )->publish; ?> <?php $counter = 1; ?> <section class="offer-list"> <div class="container"> <?php $args = array( 'post_type' => 'offer', 'posts_per_page' => 50 ); $the_query = new WP_Query( $args ); ?> <?php while ( $the_query->have_posts() && $counter <= $countOffers ) : $the_query->the_post(); ?> <?php if ( $counter % 2 != 0 ): ?> <?php get_template_part( 'template-parts/Offer/content', 'left' ); ?> <?php else: ?> <?php get_template_part( 'template-parts/Offer/content', 'right' ); ?> <?php endif ?> <?php ++$counter; ?> <?php endwhile; ?> <?php wp_reset_postdata(); ?> </div><!-- /.container --> </section>
A tutaj kod podstrony content-xxx.php – w obu szablonach zmienia się jedynie układ, ale problem jest tylko w szablonie ładowanym w 'else’.
<div class="offer-item right-side"> <div class="row vertical-align"> <div class="col-lg-7 col-md-7 col-sm-12 col-xs-12"> <div class="item-content"> <div class="item-heading"> <h1><?php the_title(); ?></h1> </div><!-- /.item-heading --> <div class="item-description"> <blockquote> <?php the_content(); ?> </blockquote> </div><!-- /.item-description --> <div class="item-offer-range"> <h3>Zakres usług</h3> <ul> <?php query_posts('cat=' . get_field( "offer_service-category" ) . ''); ?> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <li> <a href="<?php echo get_permalink(); ?>" title="<?php the_title(); ?>"> <?php the_title(); ?> </a> </li> <?php endwhile; endif; ?> <?php wp_reset_query(); ?> </ul> </div><!-- /.item-offer-range --> </div><!-- /.item-content --> </div><!-- /.col-lg-7 col-md-7 col-sm-12 col-xs-12 --> <div class="col-lg-5 col-md-5 col-sm-12 col-xs-12"> <?php var_dump( get_field( "offer_thumbnail" ) ); ?> <img src="<?php echo wp_get_attachment_url( get_post_thumbnail_id( $post->ID ) ); ?>" alt="" class="img-responsive pull-left" /> </div><!-- /.col-lg-5 col-md-5 col-sm-12 col-xs-12 --> </div><!-- /.row --> </div><!-- /.offer-item -->
Teraz w czym problem – otóż w szablonie, który jest ładowany w 'else’, pobierana jest zła miniatura wpisu, a dokładniej nie tego wpisu co trzeba ale nagłówka strony, tutaj jak to wygląda w praktyce:
http://client.vrs-factory.pl/Evarno-pl/_cms/oferta/Wie ktoś może dlaczego tak się dzieje?
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- Temat ‘Co drugi post pobiera złą miniature’ jest zamknięty na nowe odpowiedzi.