This is what I have so far. Unfortunately this grabs ALL my pages’ titles and content including sub-pages. I only want to display top-level main pages. How can I do this?
<?php query_posts('post_type=page'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php the_title(); ?>
<?php the_content(); ?>
<?php endwhile; endif; ?>
*Note: I want to display both title and content for the pages. Not just title. Otherwise I would use:
<?php wp_list_pages('depth=1'); ?>
UPDATE: Following konsolenfreddy’s advice I was able to loop through my pages properly. However a new problem arose. The content is being striped of its tags. Anyway I can keep them? Here’s my new code:
<?php
$pages = get_pages('parent=0');
foreach ($pages as $pagg) {
$option .= $pagg->post_title;
$option .= $pagg->post_content;
echo $option;
}
?>
You can use
get_pages()
(see http://codex.wordpress.org/Function_Reference/get_pages ), it takes the same arguments aswp_list_pages()
Does this work?