0

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();?>

1 Answer 1

4

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().

Sign up to request clarification or add additional context in comments.

7 Comments

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; ?>
You want to output the content of the page? See the updated answer.
Worked like a charm, thank you, I'll accept your answer once I can ;)
One quick question, if there are several pages, how can I get a specific one out? e.g. depending on title or something?
You can access the title using the_title(). But you can specify the ID in the params, though.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.