2014-03-04 5 views
0

각 WP 포스트를 개별적으로 스타일링하고 잠시 후 루프가 자동으로 각 새 게시물을 자신의 div에 할당 할 수 있기를 바랍니다. 예를 들어 :wordpress 자신의 div에있는 각 게시물을

<div id="blog-content-wp"> 
<?php while(have_posts()): the_post()?> 
    <?php $myposts = get_posts(''); 
    foreach($myposts as $post) : 
    setup_postdata($post); 
    ?> 
<?php the_content(); ?>   
<?php endforeach; wp_reset_postdata(); ?> 
<?php endwhile;?> 
<?php comments_template('', true);?> 
</div> 

모든이 블로그 콘텐츠 WP 안에 내 게시물을 모두 넣어 않으며, 내가 달성하고자하는 모든 별도의 사업부입니다 :

<div id="blog-content-wp"> 
    <div class="post"> 
    Post 1 
    </div> 
    <div class="post"> 
    Post 2 
    </div> 
</div> 

이 지금까지 내 코드입니다 각 게시물에 대해.

제안 사항? 나는이 중복 될 수 알지만, 지금까지 내가 본 모든이 "어떻게 DIV 당 세 개의 게시물을 얻을"등

감사

답변

2

밖으로 인쇄 전화 감싸 루프 내부의 새로운 div가있다 the_content()

<div id="blog-content-wp"> 
<?php while(have_posts()): the_post()?> 
    <?php $myposts = get_posts(''); 
    foreach($myposts as $post) : 
    setup_postdata($post); 
    ?> 

<div > 
<?php the_content(); ?>   
</div > 

<?php endforeach; wp_reset_postdata(); ?> 
<?php endwhile;?> 
<?php comments_template('', true);?> 
</div> 
+0

매우 감사합니다. 내가 필요한 것. – Myles

0

포스트 클래스와 그것을 할, 태그, 클래스와 더 많은

<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>> 
    <?php the_content(); ?> 
    </div> 

전체 심판 :
와 클래스를 제공합니다

관련 문제