Is it possible to display the content of all the pages under a single page?? Like, I have Home, About and Contact us pages. I want all of its contents to display under a single frontend page. Is it possible and how can we do it?
2 Answers
This is really pretty trivial to implement. A few minutes with the Codex should solve the problem, really.
$args = array(
'post_type' => 'page',
'posts_per_page' => -1,
);
$q = new WP_Query($args);
if ($q->have_posts()) {
while ($q->have_posts()) {
$q->the_post();
the_title();
the_content();
}
}
Any additional markup and formatting (CSS), of course, is up to you.
Try placing the following code under index.php for each post, where PAGE_ID_GOES_HERE is the ID number of the post.
<?php
$id=PAGE_ID_GOES_HERE;
$post = get_post($id);
$content = apply_filters('the_content', $post->post_content);
echo $content;
?>
To find the ID number of the page, look at the URL of the post-edit page; for example, in http://yourwebsite.com/wp-admin/post.php?post=8&action=edit post=8 tells you that the ID number is 8.