Pages, like posts, are stored in the database as
post_types, the big difference here is that pages lives outside the normal time-based listing. Check at what the codex say
What Pages Are:
- Pages are for content that is less time-dependent than Posts.
- Pages can be organized into pages and subpages.
- Pages can use different Page Templates which can include Template Files, Template Tags and other PHP code.
- Pages may have a more complex array of readily available display adjustments when using sophisticated Themes with extensive customization.
- In essence, Pages are for non-blog content. It is possible to remove all or most Posts from a WordPress installation, and thus to create a standard non-blog website.
What Pages are Not:
- Pages are not Posts, nor are they excerpted from larger works of fiction. They do not cycle through your blog's main page. WordPress Plugins are available to change the defaults if necessary.
- Pages cannot be associated with Categories and cannot be assigned Tags. The organizational structure for Pages comes only from their hierarchical interrelationships, and not from Tags or Categories.
- Pages are not files. They are stored in your database just like Posts are.
Although you can put Template Tags and PHP code into a Page Template file, you cannot put these into the Page or Post content without a WordPress Plugin like Exec-PHP which overwrites the code filtering process.
- Pages are not included in your site's feed.
- Pages and Posts may attract attention in different ways from humans or search engines.
- Pages (or a specific post) can be set as a static front page if desired with a separate - - Page set for the latest blog posts, typically named "blog."
Pages are mainly used for non-blogging purposes, and will suite your needs perfectly. You can have a look at how to create page templates in the codex.
To come to your question, all information entered into a page is stored in the database, just as posts are, but unlike posts which is stored as
post, pages are stored as
page. To get that and display these information, you have to make a query to the database to call that information.
Here is how the main query determine what information to return when a page loads, Taken from Query Overview
So, here are the steps WordPress uses to decide what posts or pages to display on a page, and display them:
- When a visitor first clicks on or types a URL for a page that is part of your blog, WordPress starts by running a few core files (wp-config.php, wp-settings.php, etc.) If you are interested in the specifics of the file loading order, start at index.php and follow the chain of files as each PHP file includes/requires additional PHP files (or read this excellent post at humanshell.net)
- WordPress loads and initializes any plugins you have activated (calls the plugin init actions).
- WordPress loads the "text domain" for internationalization, and the functions.php file from the currently active theme.
- WordPress runs the wp() function (in wp-includes/functions.php), which calls $wp->main() ($wp is an object of class WP, which is defined in wp-includes/class-wp.php). This tells WordPress to:
-Parse the URL into a query specification using WP->parse_request() -- more on that below.
- Set all the is_ variables that are used by Conditional Tags using $wp_query->parse_query() ($wp_query is an object of class WP_Query, which is defined in wp-includes/query.php). Note that in spite of this function's name, in this case WP_Query->parse_query doesn't actually do any parsing for us, since that is done before-hand by WP->parse_request().
- Convert the query specification into a MySQL database query, and run the database query to get the list of posts, in function WP_Query->get_posts(). Save the posts in the $wp_query object to be used in the WordPress Loop.
- Handle 404 errors.
- Send the blog's HTTP headers.
- Set up some variables for the WordPress Loop.
- WordPress loads your template, figures out which template file to use according to the Template Hierarchy, and runs that file (basically doing whatever your template file says to do). Or, WordPress could run one of the feed files (such as wp-rss2.php) instead.
Generally, the template or feed file runs the WordPress Loop to print blog posts or a static page.
- The template or feed file will also likely print out permalinks to some archives, categories, or posts using built-in WordPress functions.
I understand that:
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
is used for a page that is pulling x number of posts, however in my scenario, I only want to pull the contents of a page rather than x number of posts
So the answer to this question is, the loop only output the information/data from the main query. It is the main query that retrieves the data from the database, and as said before, the main query retrieves only the information according to URL and post type
Do I need to create custom SQL queries?
No, the main query has alreaady done that. You can just use
the_post() to get that information from the main query(). If you need to make custom queries, rather use
WP_Query. Never use your own SQL queries
If I'm just using static pages, do I even need to use The Loop?
It is not necessary, you can just simply use
the_post() to display your information. It is however good practice to use the loop, as
have_posts() triggers the loop end when the loop reaches the end.
I hope this explains as much issues you might have. If I can leave you with this, never try to reinvent the wheel, but that doesn't mean you cannot improve on the design if that day comes. But for now, stick to the basics, and make use of the default loop almost always.