Difference between revisions of "Week Eleven (MGDP2060)"
Karl Jones (Talk | contribs) |
Karl Jones (Talk | contribs) (→In the News) |
||
Line 5: | Line 5: | ||
== In the News == | == In the News == | ||
− | * [http://boingboing.net/2016/11/08/winter-denial-of-service-attac.html Denial of Service attack knocks out heating in Finnish homes] - the attack brought down the buildings' access to [[DNS]], causing the automated systems to cycle every five minutes, until the heat, ventilation and water all shut down. | + | * [http://boingboing.net/2016/11/08/winter-denial-of-service-attac.html Denial of Service attack knocks out heating in Finnish homes] - the attack brought down the buildings' access to [[Domain Name System|DNS]], causing the automated systems to cycle every five minutes, until the heat, ventilation and water all shut down. |
== Displaying post thumbnail (featured image) == | == Displaying post thumbnail (featured image) == |
Revision as of 15:49, 10 November 2016
This article lists topics for week eleven of Web Design and Development III (MGDP2060).
See also Week Ten and Week Twelve.
Contents
- 1 In the News
- 2 Displaying post thumbnail (featured image)
- 3 Making a Smarter Product Page
- 4 Highlighting Products on Sale
- 5 Cleaning Out the Templates (536)
- 6 Creating single-product.php (537)
- 7 Creating content-single-product.php
- 8 Custom Fields (539)
- 9 Advanced Custom Fields (WordPress plugin)
- 10 Displaying custom fields in custom post types
- 11 Classifying Your Posts with Custom Taxonomies (542)
- 12 Exercises
In the News
- Denial of Service attack knocks out heating in Finnish homes - the attack brought down the buildings' access to DNS, causing the automated systems to cycle every five minutes, until the heat, ventilation and water all shut down.
Displaying post thumbnail (featured image)
Use this code to display the post thumbnail (featured image) for an individual post:
// check if the post has a Post Thumbnail assigned to it. if ( has_post_thumbnail() ) { the_post_thumbnail(); } the_content();
Making a Smarter Product Page
Individual product pages display unnecessary information, like author name.
Individual product pages are displayed by the single.php
template.
Highlighting Products on Sale
The "Better Home Page" example is meant for smaller websites, where the number of items is small enough to display well on the home page.
Larger websites, with a large number of items, may need some other approach.
For example a "Products on sale" or "Featured" category.
Each product belongs to both "Sofas" and "Featured" categories.
Or perhaps "Featured1", "Featured2", and "Featured3", corresponding to three columns.
Cleaning Out the Templates (536)
Individual product pages are displayed by the single.php
template.
The single.php
template gets help from another template, depending on type of content it's displaying.
Ordinary posts use the content-single.php
template to do the work.
When displaying a post that uses a custom post type, WordPress automatically looks for a template file in this form:
single-type.php
Where type is the registered name of the custom post type, in this case "product":
single-product.php
Use this template to display content for individual products.
Creating single-product.php (537)
Make a copy of single.php
. Name the copy single-product.php
.
Remove the navigation links.
Modify the get_template_part
function:
<?php get_template_part( 'content', 'single-product' ); ?>
Creating content-single-product.php
Make a copy of content-single.php
. Name the copy content-single-product.php
.
Custom Fields (539)
Advanced Custom Fields (WordPress plugin)
See Advanced Custom Fields (WordPress plugin).
Displaying custom fields in custom post types
Find the code for 'Products' custom post type in functions.php
as shown below:
'supports' => array ( 'title', 'editor', 'thumbnail', 'excerpt'),
Add code, the new code looks like this:
'supports' => array ( 'title', 'editor', 'thumbnail', 'excerpt', 'custom-field'),
This will add custom field(s) to the screen options for Products. See below for more information about custom fields.
Classifying Your Posts with Custom Taxonomies (542)
You add custom taxonomies of your own: like Categories or Tags, but using terminology customized for a specific purpose.
See