2010-12-13 9 views
3

내 포트폴리오의 메뉴 역할을하는 상위 페이지가 있습니다.하위 페이지 콘텐츠

마술 필드 및 일부 코드로 수행 할 수있는 하위 페이지의 이미지를 가져옵니다. 이미지를 그리드 레이아웃으로 덤프합니다. 축소판은과 같이 하나 개의 컨테이너 사업부에 들어갔습니다됩니다 사업부는 2 썸네일과 함께 채워집니다

div id="folio-content"> 

<div class="thumb-container"> 
<div class="thumb"><img src="/images/pic.jpg"/> 
</div>JCPenny</div> 
... </div>` 

나는 새로운 컨테이너 사업부를 만들고 다시 등 2 개 이미지 후이 개 이미지를 채우려.

네 이미지가 있다면 이렇게 보일 것입니다.

<div id="folio-content"><!--/Main Container/--> 
<div class="thumb-container"> 
<div class="thumb"><img src="/images/pic1.jpg"/> 
</div>JCPenny</div> 
<div class="thumb-container"> 
<div class="thumb"><img src="/images/pic1.jpg"/> 
</div>Champ Car</div></div> 

<div id="folio-content"><!--/Main Container/--> 
<div class="thumb-container"> 
<div class="thumb"><img src="/images/pic1.jpg"/> 
</div>JCPenny</div> 
<div class="thumb-container"> 
<div class="thumb"><img src="/images/pic1.jpg"/> 
</div>Champ Car</div></div> 



this is the code I am using in my page.php file. 

    <?php get_header(); ?> 

<div id="folio-content"> 

<?php 
$projectpage = get_pages('child_of='.$post->ID.'&sort_column=post_date&sort_order=desc'); 

$count = 0; 
foreach($projectpage as $page) 
{ 
$content = $page->post_content; 
if(!$content) 

continue; 
if ($count == 10) --- this is geting 10 images now, but I want to get them all. 

break; 
$count++; 

$content = apply_filters('the_content', $content); 

?> 
<div class="thumb-container"> 
<div class="thumb"><a href="<?php echo get_permalink($page->ID); ?>"<?php echo get_image ("thumbnail",1,1,1,$page->ID);?></a> 
</div><?php echo $page->post_title ?> 
</div> 
<?php 
} 
?> 
</div><!--/close set!--> 
</div> 

또한 어떻게 모든 하위 페이지를 가져올 수 있습니까? 나는 이것을 10으로 지금 맞추었습니다 if ($count == 10)

어떤 도움이 필요합니까? 다시 한번 고마워 !!!!

답변

1

나는 "get_pages"에 익숙하지 않지만 Wordpress는 게시물과 페이지를 동일한 방식으로 취급하므로 사용자는 이것을 사용할 수 있습니다.

$projectpage = get_posts('numberposts=-1&post_type=page&child_of='.$post->ID.'&sort_column=post_date&sort_order=desc'); 

-1은 제한을 제거하고 지정된 모든 페이지를 가져옵니다.

+0

감사합니다. 이 코드는 좋고 모든 하위 페이지를 가져옵니다 ... 그래서 해결되었습니다. .. 감사합니다! – chad

0

나는 몇 가지 코드를 함께 자필했다. 그런 종류의 소리는 좋지만 전혀 작동하지 않는다! 나는 놀랍지 않다. 그러나 그것은 출발점입니다.이 코드를 살펴보십시오. 아마도 올바른 방향으로 나아갈 것입니까?

<?php 
$projectpage = get_posts('numberposts=-1&post_type=page&child_of='.$post->ID.'&sort_column=post_date&sort_order=desc'); 
if (have_posts()) : 
    $i=0; // counter 
    while(get_posts()) : the_post(); 
     if($i%2==0) { // if counter is multiple of 3, put an opening div ?> 
     <!-- <?php echo ($i+1).'-'; echo ($i+2); ?> --> 
     <div> 
     <?php } ?> 
    <div class="single_item"> 
    <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2> 
    </div> 
     <?php $i++; 
     if($i%2==0) { // if counter is multiple of 3, put an closing div ?> 
     </div> 
     <?php } ?> 

    <?php endwhile; ?> 
     <?php 
     if($i%2!=0) { // put closing div here if loop is not exactly a multiple of 3 ?> 
     </div> 
     <?php } ?> 

<?php endif; ?> 
관련 문제