2009-06-25 9 views
0

각 하위 페이지 (하위 페이지 제외)에 대한 항목을 나열하고 페이지 이름과 사용자 지정 필드를 기반으로 몇 가지 항목을 표시 할 페이지 서식 파일이 있습니다. 어떻게하면 좋을까요?Wordpress 검색 게시 하위

워드 프레스 사용 2.8

답변

3

다음은 내 페이지 템플릿의 마지막 부분입니다.

$pages =& get_children('post_type=page&orderby=title&order=ASC&post_parent='.get_the_ID()); 

if (empty($pages)) { 
    // no attachments here 
} else { 
    foreach ($pages as $attachment_id => $attachment) { 
     <? 
     <h3><? echo get_the_title($attachment_id); ?></h3> 
     <p><a href="<? echo get_permalink($attachment_id)?>">View more</a></p> 
     <? 
    } 
} 
0

나는 내 사이트에서 비슷한 것을하고 있습니다. 자신의 페이지 템플리트를 정의해야합니다. 템플릿 디렉토리에 파일을 만들고 거기에 붙여 넣으십시오. 어쨌든 시작하십시오. 그런 다음 상위 페이지를 편집하고 속성 상자에서 템플리트의 상위 페이지를 선택하십시오.

이 예제에는 각 하위 페이지의 전체 내용이 포함되지만 원하는대로 사용자 지정할 수 있습니다.

<?php 
/* 
Template Name: Parent Page 
*/ 
?> 
<?php 
/** 
* Loop over all sub-pages and include their content 
*/ 
the_post(); 
$children = get_pages("child_of=" . $post->ID); 
$childIDs = array(); 
foreach($children as $c) { 
    $childIDs[] = (int)$c->ID; 
} 

query_posts(array('post_type'=>'page','post__in'=>$childIDs, 'orderby'=>'menu_order')); 

get_header(); 
?> 
<div id="content"> 
    <?php if (have_posts()) : while (have_posts()) : the_post(); $loopcounter++; ?> 

     <div <?php if (function_exists('post_class')) post_class(); ?>> 

      <div class="entry entry-<?php echo $postCount ;?>"> 

       <div class="entrytitle_wrap"> 
        <?php if (!is_page()) : ?> 
         <div class="entrydate"> 
          <div class="dateMonth"> 
           <?php the_time('M');?> 
          </div> 
          <div class="dateDay"> 
           <?php the_time('j'); ?> 
          </div> 
         </div> 
        <?php endif; ?> 

        <div class="entrytitle"> 
        <?php if ($loopcounter==1):?> 
         <h1><a href="<?php the_permalink() ?>" rel="bookmark" title="Link to <?php the_title(); ?>"><?php the_title(); ?></a></h1> 
        <?php else : ?> 
         <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2> 
        <?php endif; ?> 
        </div> 

       </div> 


       <div class="entrybody"> 
        <?php if (is_archive() || is_search()) : ?> 
         <?php the_excerpt(); _e('<p><a href="'.get_permalink().'">Continue reading about '); the_title(); _e('</a></p>'); ?> 
        <?php else : ?> 
         <?php the_content('Read the rest of this entry &raquo;'); ?> 
         <?php the_tags('<p>Tags: ', ', ', '</p>'); ?> 
        <?php endif; ?>   
       </div> 

       <div class="entrymeta"> 
        <div class="postinfo"> 
         <?php edit_post_link('Edit', '', ''); ?>     
        </div> 
       </div> 


       <?php if ($loopcounter == 1 && !is_singular()) { include (TEMPLATEPATH . '/ad_middle.php'); } ?>     

      </div> 

    </div> 

    <?php endwhile; ?> 

    <?php if (!is_singular()): ?>   
     <div id="nav-global" class="navigation"> 
      <div class="nav-previous"> 
      <?php 
       next_posts_link('&laquo; Previous entries'); 
       echo '&nbsp;'; 
       previous_posts_link('Next entries &raquo;'); 
      ?> 
      </div> 
     </div> 

    <?php endif; ?> 

    <?php else : ?> 

     <h2>Not Found</h2> 
     <div class="entrybody">Sorry, but you are looking for something that isn't here.</div> 
    <?php endif; ?> 

</div> 

<?php get_footer(); ?>