Difference between revisions of "Week Nine (MGDP2060)"

From Wiki @ Karl Jones dot com
Jump to: navigation, search
(Adding New Types of Posts: Custom Post Types)
Line 32: Line 32:
 
* Pick a Theme Framework -- simple, foundational Themes design for developers to extend.
 
* Pick a Theme Framework -- simple, foundational Themes design for developers to extend.
 
** Many Frameworks exist, each with its own features.
 
** Many Frameworks exist, each with its own features.
 +
** See [https://codex.wordpress.org/Theme_Frameworks Theme Frameworks] @ codex.wordpress.org.
  
 
== Creating a Custom Copy of a WordPress Theme ==
 
== Creating a Custom Copy of a WordPress Theme ==

Revision as of 14:05, 23 October 2016

This article lists topics for Week Nine of Web Design and Development III (MGDP2060).

Textbook: Building an Advanced WordPress Site (505-518)

Planning Your Site

Questions to ask when planning a site:

  • What type of content?
    • Blog (News, Press Release, etc.)
    • Product catalog
    • "Static" content
  • How will the content be arranged?
  • How will users navigate the site?
  • Will the content use WordPress Pages, WordPress Posts, or both?
  • Will the site use WordPress Custom Posts?
    • For example, Products, where each Custom Post is a product.

See also Web usability.

Picking a Theme

All WordPress Themes have principles in common, but each Theme is unique.

Web designers may have different approaches to Custom Copy Theme design:

  • Pick a Theme you understand well, and customize for all customization projects.
  • Pick a Theme that is as close as possible to the final result.
    • Less work to do, but requires more detailed knowledge about how the Theme works.
  • Create a minimal, stripped-down Theme, which provides a minimum of WordPress core functionality.
    • Then customize the minimal Theme.
  • Pick a Theme Framework -- simple, foundational Themes design for developers to extend.
    • Many Frameworks exist, each with its own features.
    • See Theme Frameworks @ codex.wordpress.org.

Creating a Custom Copy of a WordPress Theme

You can create a "clone" of a existing WordPress Theme by:

  • Copying the entire Theme folder, and pasting it with a new folder name
  • In the new style.css file, renaming the Theme

You then edit your new Theme.

This is more complex than creating a WordPress Child Theme. Child Themes are convenient for style changes. For complete control of a Theme, use a Custom Copy.

Avoiding Confusion with a Test Site

In professional web design, it is common to create a test website which exists somewhere other than the URL for the actual website.

Adding New Types of Posts: Custom Post Types

In WordPress, a Custom Post Type is a variation on the standard WordPress Post.

A Custom Post Type has its own name, which appears in the WordPress Dashboard menu, and its own set of associated Posts, separate from the standard Posts.

Custom Posts are created and edited in the same manner as standard Posts.

Defining a Custom Code Type in Code

You can create a Custom Post Type by entering PHP code into the functions.php file.

This is the hard way to create a Custom Post Type. Consider using a plugin (see below) instead.

Creating a Custom Post Type That Suits Your Site

Custom Post Types are used for a wide range of purposes.

When creating a Custom Post Type, choose a name that suits your site. For example:

  • An e-commerce system might use a Custom Post Type named "Products"
  • A portfolio might use the name "Portfolio", "Works", "Painting", etc.
  • A publishing house: "Publications", "Books", etc.
  • A medical practice might use the name "Doctors", "Staff", etc.

Refreshing the Permalink Settings

After creating a new Custom Post Type, you must refresh the Permalink settings:

  • Choose Settings->Permalinks in the Dashboard.
  • Select one of the "pretty" permalink settings, such as Post Name.
  • Click Save Changes, even if you haven't saved anything.

Creating Sample Content

After creating a Custom Post Type, and refreshing the Permalink settings, you can create content for your Custom Posts, similar to the way you creating content for standard Posts.

The name of your Custom Post Type ("Products", for example) will appear in the Dashboard sidebar.

Click the "Products" link to Add, Edit, and Delete content for your Products. These features behave like the standard Post features.

Each new Custom Post has its own Permalink.

Note that name of the Custom Post Types (e.g. "Products") appears in the URL for Product pages.

Making Your Custom Post Type Appear on Your Site

Posts associated with Custom Post Types do not automatically appear on then Home Page, nor on the WordPress Archive Pages.

There are two ways to make your Custom Post Types appear on these pages.

  • Create custom WordPress Template for the Archive pages which display Custom Post Types.
  • Add code to functions.php which tells WordPress to display your Custom Posts on the existing Archive pages.

Editing Custom Post Types

"I created a custom post type and added some posts that use it. Now I want to change the custom post type. Is it safe?"

Yes, you can edit your Custom Post Types.

Caveat: if you change the lower-case name, the existing Posts will be lost.

If you remove a Custom Post Type, first delete the Custom Posts (so they are not left behind as orphan data).

Defining a Custom Post Type with a Plug-in

Using a plugin simplifies the process of creating a Custom Post Type.

Popular plugins include:

Exercises

See Week Nine Exercises (MGDP2060).