I am developing a one page WordPress theme, there is no need to display any posts, it's just informative page, I was thinking to use static content, but it turned out that I'll need to use dynamic one in order for things like search to work. In "pages" section of WordPres I created a new page which contains all the content I need, I was trying to figure out a loop to include contents of that page, but failed. After doing a research I was only able to find loops used to display content of posts. So is there same loop, but to display contents of page? Also How would I than include those contents in a page e.g.
<?php something();?>
Add a comment
|
1 Answer
Just specify the post_type inside of the query_posts() parameter. For example, if you wanted to output the content of each page, you could do this:
query_posts(array('post_type' => 'page'));
while(have_posts())
{
echo the_content();
}
For reference, you might want to check out the API Reference Docs for query_posts().
7 Comments
Ilja
Okay, so that loop gets pages instead of posts correct? One last question, how would I then include pages I got from the loop to my page? is it <?php echo $this_page; ?>
BenM
You want to output the content of the page? See the updated answer.
Ilja
Worked like a charm, thank you, I'll accept your answer once I can ;)
Ilja
One quick question, if there are several pages, how can I get a specific one out? e.g. depending on title or something?
BenM
You can access the title using
the_title(). But you can specify the ID in the params, though. |