Translate

Monday, 1 October 2018

Understanding WordPress Pages and the Pages API

There are differences between WordPress posts and pages. There are times when a post is more suitable to use, while for other types of content, a page is more appropriate. In this article, I’ll cover what pages are and why they are different to posts. I’ll then show you how to manage pages on a WordPress website. Finally, we’ll take a look at some functions in the WordPress Pages API and have a play with pages.

What Is a WordPress Page?

A WordPress page is a page of content on your website — for example, a “Contact” or “About” page. We often see links to these pages in the main navigation, sidebar, or the perhaps in the footer of the website.

The main difference between a post and a page is the context in time: a post is generally time-dependant, while the content within a page is often permanent.

When you publish news, or even a tutorial, the context is important. A new feature won’t be new forever, and in some cases might not exist some years later. That’s why a post is more adapted when writing this type of content.

On the other hand, if you want to describe the purpose of your website, or if you want to provide a contact form, you’ll want to use a page. It’s the type of static content that won’t change in time.

How To Manage WordPress Pages

Adding, Editing and Removing a Page

If you have Editor or Administrator permissions, you can manage the pages in WordPress. To do this, go to Pages in the WordPress dashboard, and you’ll see a list of all your pages or to create a new page via the Add New button.

WordPress Pages API

This list is similar to the list found in Posts, and can be used in the same way. You can click on a page’s title to edit it and some other useful quick links appear when you move your mouse over the page’s title.

When you click to edit or add a page or post, you can then specify the title, content, and even add a featured image if your theme supports it. The Publish button allows you to publish the page. Otherwise, if you’re not ready to make it live, you can save it as a draft.

Organizing Pages

To organize your posts, you can use categories and tags. However, there isn’t a similar way to organize pages. Pages can still be organized in a hierarchy. In fact, you can indicate pages as subpages of other pages. It’s exactly like creating subcategories for your categories.

To create a subpage, go to the Page Attributes box where you’ll find a dropdown list labelled Parent. In this list, select the page you want as the parent of the page you’re currently creating or editing. Note, you can also create sub-subpages, sub-sub-subpages, etc. to create your own hierarchy.

By default, the pages are sorted alphabetically (by their titles). You can customize this order thanks to the Order field in the Page Attributes section. Then the pages will be sorted following the number you indicate in this field. As an example, if you have three pages titled Page 1, Page 2 and Page 3, they’ll be displayed in this order by default. If you want to make Page 3 appear first, indicate 0 as its order, and bigger numbers for the other pages (1 and 2 for instance).

The post Understanding WordPress Pages and the Pages API appeared first on SitePoint.



No comments:

Post a Comment