2014-01-16 3 views
1

나는 네 가지 카테고리로 홈페이지를 만들었습니다. 잘 작동한다고 생각하지만, 현재 모든 게시물은 첫 번째 게시물과 동일한 내용을 가지고 있습니다. 링크 및 추천 이미지는 훌륭하지만 텍스트가 어떻게 든 덮어 쓰기되고 있습니다.wordpress 게시물 콘텐츠 중복

Heress 화면의 모든 텍스트가 같은 :

http://imagizer.imageshack.us/v2/800x600q90/713/m1j6.jpg

편집 : 그래서이 <?php setup_postdata($post); ?> 작동 내부 루프

내 코드 :

<div class="bmw"> 
    <h2>bmw news</h2> 
     <?php $k = 1; 
     $posts = get_posts('category=7&orderby=date&numberposts=2'); foreach($posts as $post) { ?> 
    <?php setup_postdata($post); ?> 
    <div id="home_post<?php if($k%2 == 0) echo "last" ;?>"> 

    <?php if (has_post_thumbnail()) {?> 
    <a href="<?php the_permalink() ?>"><div id="img"> 
    <span> 
    <?php the_post_thumbnail(); ?> 
     </span> 
    </div> 
     </a> 
    <?php }; ?> 
    <a href="<?php the_permalink() ?>"><h3><?php the_title(); ?></h3></a> 
    <span id="tags"><?php the_tags(); ?></span> 
    <?php the_content('...'); ?> 
     <div class="button_more"><a href="<?php the_permalink() ?>">Czytaj więcej<span><img style="vertical-align:middle;width:auto;margin-left:5%" src="http://test.startujac.pl/images/strzalka_czytaj_wiecej.png"></span></a></div> 
    </div> 
    <?php $k++; ?> 
    <?php } ?> 
    </div> 

<div class="news"> 
    <h2>VW news</h2> 
    <?php $v = 1; 
     $posts = get_posts('category=12&orderby=date&numberposts=2'); foreach($posts as $post) { ?> 
     <?php setup_postdata($post); ?> 
     <div id="home_post<?php if($v%2 == 0) echo "last" ;?>"> 
    <?php if (has_post_thumbnail()) {?> 
     <a href="<?php the_permalink() ?>"><div id="img"> 
    <span> 
    <?php the_post_thumbnail(); ?> 
    </span> 
    </div></a> 
     <?php } ?> 
    <a href="<?php the_permalink() ?>"><h3><?php the_title(); ?></h3></a> 
    <span id="tags"><?php the_tags(); ?></span> 
    <?php the_content('...'); ?> 
     <div class="button_more"><a href="<?php the_permalink() ?>">Czytaj więcej<span><img style="vertical-align:middle;width:auto;margin-left:5%" src="http://test.startujac.pl/images/strzalka_czytaj_wiecej.png"></span></a></div> 
    </div> 
    <?php $v++; ?> 
     <?php }?> 
    </div> 
<div class="japan"> 
    <h2>japan news</h2> 
     <?php $k = 1; 
     $posts = get_posts('category=13&orderby=date&numberposts=2'); foreach($posts as $post) { ?> 
     <?php setup_postdata($post); ?> 
     <div id="home_post<?php if($k%2 == 0) echo "last" ;?>"> 
     <?php if (has_post_thumbnail()) {?> 
     <a href="<?php the_permalink() ?>"><div id="img"> 
     <span> 
     <?php the_post_thumbnail(); ?> 
    </span> 
    </div></a> 
    <?php } ?> 
     <a href="<?php the_permalink() ?>"><h3><?php the_title(); ?></h3></a> 
     <span id="tags"><?php the_tags(); ?></span> 
     <?php the_content('...'); ?> 
     <div class="button_more"><a href="<?php the_permalink() ?>">Czytaj więcej<span><img style="vertical-align:middle;width:auto;margin-left:5%" src="http://test.startujac.pl/images/strzalka_czytaj_wiecej.png"></span></a></div> 
    </div> 
    <?php $k++; ?> 
     <?php } ?> 
    </div> 



     <div class="events"> 
     <h2>imprezy i zloty</h2> 
     <?php $k = 1; 
     $posts = get_posts('category=1&orderby=date&numberposts=4'); foreach($posts as $post) { ?> 
     <?php setup_postdata($post); ?> 
    <div id="home_post<?php if($k == 1) echo "first" ;?>"> 
    <?php if (has_post_thumbnail()) {?> 
    <div id="img"> 
     <span> 
    <?php the_post_thumbnail(); ?> 
    </span> 
     </div> 
    <?php } ?> 
     <div id="content"> 
     <h3><?php the_title(); ?></h3> 
    <span id="tags"><?php the_tags(); ?></span> 
    <?php the_content('...'); ?> 
     </div> 
     </div> 
    <?php $k++; ?> 
     <?php } ?> 
     </div> 

답변

0

the_post(); 퍼팅 시도 되세요 템플릿 파일의 시작 부분에? 이것은 때로는 이런 종류의 문제를 해결합니다.

+0

아니,하지만, 정확히 무슨 뜻이야;)? index.php 파일에이 코드가 있습니다. 그래서 나는 shud 내가 그것을 두는 곳? '

+0

다음과 같이 PHP 태그에 넣어야합니다 :'

+0

하지만 위 코드에서 제공 한 파일이이 파일에 포함되어 있습니까? 또는 다른 템플릿 파일? 나는 이것을 추가했지만 아무것도 바뀌지 않았다. –