Difference between revisions of "Week Eleven (MGDP2060)"

From Wiki @ Karl Jones dot com
Jump to: navigation, search
(Classifying Your Posts with Custom Taxonomies (542))
(Classifying Your Posts with Custom Taxonomies (542))
Line 85: Line 85:
 
See  
 
See  
  
* [[Custom Post Type UI]]
+
* [[Custom Post Type UI (WordPress plugin)|Custom Post Type UI]]
 
* [[WordPress Custom Taxonomy]]
 
* [[WordPress Custom Taxonomy]]
  

Revision as of 19:35, 7 November 2016

This article lists topics for week eleven of Web Design and Development III (MGDP2060).

See also Week Ten and Week Twelve.

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)

"Screen options" may not behave as shown in book.

Try creating new post, then setting screen options.

See WordPress Custom Field.

Advanced Custom Fields (WordPress plugin)

See Advanced Custom Fields (WordPress plugin).

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

Exercises

See Week Eleven Exercises (MGDP2060).