Pages are one of the defining features of WordPress. Not just because they are different from Posts, which are category and tag based, but also because you can feature a Page as your sites front page. With the added functionality that templates provide, the sky (metaphorically speaking) has become the limit for theme designers and developers.
Here are five code snippets you can use to enhance what you can do with a Page!
Featured Plugin - WordPress Infinite SEO Plugin
1. Show specific WordPress Post/Page: Code used to get the content, title, excerpt, etc for a specific Page or Post. This code is perfect for showing specific content on a Page template.
2. WordPress get attachements for Post or Page: Gets a Post or Page’s attached images and outputs them. A nice piece of code to show a gallery of thumbnails perhaps.
3. List WordPress sub Pages: As the description states, you can use this code snippet in your template file to show all sub Pages for a particular Page. Example uses may include a list of employees by job, where each employee is a sub Page of a department.
4. If Page is Parent or Child: May sound a bit complex, but actually it’s a handy little piece of code. Check out the example provided by Chris and how it works.
5. Create a New Page: No, this is not done with the “Add New” button. Rather, this is done by a themes functions.php file. Generally used to create pages where specific content would need to be filled in. You’ll also find this being used by e-commerce plugins to create new Pages for their cart, checkout etc…
Got any code tricks of your own up your sleeve? Share them with us, leave a comment below!
Image by sociotard