Week Ten (MGDP2060)
This article lists topics for Week Ten of Web Design and Development III (MGDP2060).
See also Week Nine and Week Eleven.
Contents
- 1 In the News
- 2 x10hosting login every 30 days
- 3 x10hosting file hosting
- 4 Categories
- 5 Creating Custom Category Pages
- 6 Adding a Category Description
- 7 Finding the Right Template File
- 8 Some Themes don't have category.php
- 9 Make backups
- 10 Changing a Category Page's Title (523)
- 11 Adding Extra Information
- 12 Reordering Posts
- 13 Removing Post Footers
- 14 Different Category Pages for Different Categories
- 15 Building a Better Home Page
- 16 Cleaning Out the Template
- 17 Adding Text
- 18 Creating Links
- 19 The Multi-Column Effect
- 20 Comparing get_posts() and query_posts()
- 21 Extracting information from a Post
- 22 Topic summary
- 23 Exercises
In the News
- 2016 Dyn cyberattack - executed through a botnet consisting of a large number of Internet-connected devices—such as printers, cameras, residential gateways and baby monitors—that had been infected with the Mirai malware.
- Firefox disables loophole that allows sites to track users via battery status - researchers discovered that it was easy to abuse the feature to track browsing on the internet.
x10hosting login every 30 days
Remember that x10hosting free accounts require that you log in to your control panel every 30 days.
x10hosting file hosting
x10hosting states:
1. There no space limit, except an initial limit (1gb or 500 mb depending on if you are in a high risk country or not) that you can get lifted by request once your account is at least one week old and closing in on using up the current space (you would need to be using at least half of it to be eligible for the limit being removed). Do note that at that point your account will be reviewed as to whether it is following ToS or not. We do not allow file hosting, all files must be related to a working site.
2. You can create 3 ftp accounts with free hosting. Please do note that ToS does prohibit giving away hosting to a third party.
Source:
https://x10hosting.com/community/threads/x10-hosting-limits.178698/
See also FTP for file sharing.
Categories
The textbook example expects you to create three categories, each representing a product line:
- Sofas
- Chairs
- Tables
Creating Custom Category Pages
A Custom Category Page -- also known as a Category Archive Page -- displays Posts which belong a specific WordPress Category.
This is useful when working with Custom Post Types. For example, the "Products" custom post type has categories for product lines such as Sofas.
Features you can control when designing a category archive page:
- Title
- Description
- Products in alphabetical order, by title (as opposed to chronological order, like standard Posts)
Note that Custom post types do not display in standard Templates.
Adding a Category Description
You can add a customized description for any Category using the WordPress Dashboard.
Some Themes do not display the description. You must edit the Template file(s) yourself.
Finding the Right Template File
Hierarchy of Template files relating to Categories:
-
category-slug.php
-
category-id.php
-
category.php
-
archive.php
-
index.php
See WordPress Category Template and WordPress Template hierarchy.
Some Themes don't have category.php
Many Themes have a category.php
file, but some don't.
In a Theme without category.php
, the archive.php
file may be complex, providing different output based on Category, Tag, Author, or Date.
Make backups
Make backups.
Changing a Category Page's Title (523)
Edit the category.php
file as shown in the textbook.
Note the printf()
and single_cat_title()
functions.
Adding Extra Information
Edit the category.php
file as shown in the textbook.
Also add a style rule named #WarrantyBox
.
Reordering Posts
Add the query_posts()
function as shown in the textbook.
Note the orderby
and order
parameters.
Find and remove markup as shown in the textbook.
Different Category Pages for Different Categories
For Templates which display a specific category, use Template files named like this:
category-sofas.php
In this example, "sofas" is the slug associated with the "Sofas" category.
The slug is all lower case. If the category has two or more words separated by spaces, the slug uses hyphens rather than spaces.
Building a Better Home Page
An improved home page might display links to specific products.
This can be done automatically by adding markup and PHP code to WordPress templates.
For the following exercises, change the setting your WordPress Home Page setting from "A static page" back to "Your latest posts".
Cleaning Out the Template
In the index.php
template, delete the Loop as shown in the textbook.
Adding Text
Add text to index.php
as shown in the textbook.
Creating Links
Add markup and PHP as shown in the textbook.
The Multi-Column Effect
Use CSS class rules with the float
property.
Comparing get_posts() and query_posts()
The get_posts()
function retrieves a set WordPress Posts.
get_posts()
is usually followed by the WordPress Loop.
The query_posts()
function also retrieves a set WordPress Posts.
query_posts()
works inside the WordPress Loop.
Extracting information from a Post
WordPress functions which extract information from a Post, inside the Loop, include:
-
the_title()
-
the_permalink()
-
the_ID()
-
the_date()
-
the_time()
-
the_category()
-
the_tags()
Also:
-
get_the_title()
-
get_the_excerpt()
-
get_the_post_thumbnail()
-
get_the_author()
-
get_the_content()