17

Wordpress Custom Post Types

Embed Size (px)

Citation preview

Page 1: Wordpress Custom Post Types
Page 2: Wordpress Custom Post Types

WordPress CustomizationGoal: Gain a basic understanding of some common functions used by Clique from the WordPress PHP API, modifying the administrator user-interface, and present various data formats.

Outcomes:1. An understanding of what Post Types and Custom Fields are.2. Be able to identify when to use Custom Post Types and Custom Fields.3. Able to create and modify Custom Post Types and Custom Fields.

Page 3: Wordpress Custom Post Types

Custom Post TypesOutcomes:

1. Create two Custom Post Types using the WordPress API2. Modify an existing Custom Post Type3. Be able query and display post information within page templates4. Acknowledge when to use Custom Post Types in different situations

Page 4: Wordpress Custom Post Types

Custom FieldsOutcomes:

1. Create custom fields for different post types2. Gain an understanding of how to save, update, and delete custom post data3. Acknowledge when to use Custom Fields in different situations

Page 5: Wordpress Custom Post Types

Agenda1. Why we use various post types. 2. How do I use this in my work, best practices3. Client example, adding post type to Kendall College site. 4. Adding post type to your forked site

Page 6: Wordpress Custom Post Types

Understanding WhyWhy is it important to know how to create Custom Post Types and Fields - especially programmatically?

1. Present similar data in different ways2. Present different data in similar ways3. “Administrative Organization” - a well-organized user and programming

interface.

Page 7: Wordpress Custom Post Types

Why - Second City

● Large and complex website● Must present varying data types in

varying formats● Each “post” has multiple, varying

pieces of metadata attached to it● Data types required their own unique

categorization system

Page 8: Wordpress Custom Post Types

Why - Hampel & Co.

● Content isn’t updated regularly● Data has similar format, but needed

to be presented in different ways● Each “post” has a wide range of

varying metadata in different formats

Page 9: Wordpress Custom Post Types

Planning• Create Post Types

– Identify “groups” of data and information• What content blocks are similar?• What content blocks are different?

• Create Custom Fields– Identify data/information that should be attached to post as metadata

Best Practices/Example

Page 10: Wordpress Custom Post Types
Page 11: Wordpress Custom Post Types

Building• Required hooks

– add_action• init• save_post

• Create Post Types– register_post_type

• Create Custom Fields– add_meta_box

Best Practices/Example

Page 12: Wordpress Custom Post Types
Page 13: Wordpress Custom Post Types
Page 14: Wordpress Custom Post Types

Testing• Ensure post appears in back-end of WordPress

• Ensure data is being saved appropriately

• Loop through custom posts and fields on a page

Best Practices/Example

Page 15: Wordpress Custom Post Types

You do● Programmatically add 3 custom post

types to your own personal sites● Programmatically add 3 custom fields

to your own personal sites

Page 16: Wordpress Custom Post Types

ResourcesPost Type

● https://codex.wordpress.org/Post_Types● http://www.wpbeginner.com/wp-tutorials/how-to-create-custom-post-types-in-

wordpress/Fields

● https://codex.wordpress.org/Custom_Fields● http://www.wpbeginner.com/wp-tutorials/wordpress-custom-fields-101-tips-tricks-

and-hacks/

● https://generatewp.com/

Page 17: Wordpress Custom Post Types