2011-06-13 49 views
1

這是我到目前爲止。不幸的是,這抓住了所有我的網頁的標題和內容,包括子頁面。我只想顯示頂級主頁面。我怎樣才能做到這一點?如何從頁面循環中排除子頁面?

<?php query_posts('post_type=page'); ?> 
<?php if (have_posts()) : while (have_posts()) : the_post(); ?> 
     <?php the_title(); ?> 
     <?php the_content(); ?> 
<?php endwhile; endif; ?> 

*注意:我想顯示頁面的標題和內容。不只是標題。否則,我會用:

<?php wp_list_pages('depth=1'); ?> 

更新:繼konsolenfreddy的建議,我能夠正確地循環瀏覽我的頁面。然而出現了一個新問題。內容正在被標記爲條形碼。無論如何,我可以讓他們?這是我的新代碼:

<?php 
    $pages = get_pages('parent=0'); 
    foreach ($pages as $pagg) { 
    $option .= $pagg->post_title; 
    $option .= $pagg->post_content; 
    echo $option; 
    } 
?> 

回答

0

工作的呢?

<?php query_posts('post_type=page&post_parent='.$parent);?> 
<?php if (have_posts()) : while (have_posts()) : the_post(); ?> 
     <?php the_title(); ?> 
     <?php the_content(); ?> 
<?php endwhile; endif; ?> 
+0

不,但我更新了我原來的問題。我找到了一個工作解決方案,但解決方案存在另一個問題 – 2011-06-15 16:13:50