SlideShare une entreprise Scribd logo
1  sur  21
WP 101: Custom Fields& Custom Post
Types
Joe Querin – www.joequerin.com
WordCamp Kent - Online – May 31, 2020
@joequerin joecue
joecue
{ Overview }
• Custom Fields vs Custom Post Types
• Ways to Customize WordPress
• What is CSS?
• Need more menus?
• Questions
{ Custom Post Types }
• WordPress stores all page and post data as a
post type.
• There are actually 5 core post types
• Post – Blog Entry
• Page – Static content
• Attachment – Document, Image, Video, etc.
• Revision – Version of a Post or Page
• Menu – Navigation/Menu Item
Example Scenario
• Let’s say you have a food blog and you
want to use a custom post type to display
your recipes.
• So you use the awesome code we just
looked at, customized it to represent your
menu offerings. Created categories for
breakfast, lunch, dinner, appetizers,
desserts.
Example Scenario
• You have populated your menu with all of
your fantastic recipes.
• Life is good!
Example Scenario
• Now let’s say 3 months or 6 months, or maybe
even a whole year goes by, and everything is still
good.
• Then you find the ultimate theme, it’s great, it
looks just like you want your website to look.
• So you install it, then you activate it.
• Then later that day or the next someone emails
and asks where are your recipes, so you tell them
to click on recipes, and they ask WHERE? I’m on
your site and there are no recipes.
Example Scenario
• So you go to your site and check. Hmmm no menu….
• Then in 3…2…1.. You panic!
{ Custom Post Types }
• WordPress allows you to create your own
custom post type.
• Allows you to format content in a particular
way.
• Recipes
• Products (non-ecommerce)
• Frequently Asked Questions
• Etc.
{ Custom Post Types }
function create_post_type() {
register_post_type( 'acme_product',
array(
'labels' => array(
'name' => __( 'Products' ),
'singular_name' => __( 'Product' )
),
'public' => true,
'has_archive' => true,
)
);
}
add_action( 'init', 'create_post_type' );
Sample code from https://codex.wordpress.org/Post_Types
{ Custom Post Types }
• Plugins
– Custom Post Types UI
• https://generatewp.com/
{ Custom Fields }
• The codex defines a custom field as meta-
data, that contains a key/value pair.
• ????
{ Custom Fields }
• I’ll admit, it’s pretty technical and confusing
• If you keep reading the codex page though, you’ll
see what a key/value pair is.
• Key – the name of the meta-data
• Value – the meta-data
• Example:
– Key: Currently Reading
– Value: Calvin and Hobbes
{ Custom Fields }
• What can you do with custom fields?
• Announcement features on your website
• First create a custom post type to handle the
announcement content
– Title
– Description
– Photo
• How about an announcement start date?
{ Custom Fields }
• Create a custom field
– Start Date – built in scheduling of Post
– Display End Date
– Importance
• Using some PHP logic we can display the
content we can make the post
automatically display based upon the
server’s date as well as when to stop.
{ Custom Fields }
• Using similar PHP logic, we can even
change the CSS class or ID of the
containing element to make the
announcement appear different.
{ Customize WP }
• WordPress Customizer
• Header Image
• Site Title / Tagline
• Colors
• Additional CSS
• Jetpack Plugin
• Additional CSS option
{ Customize WP }
• Page Builders
• Gutenberg
• Beaver Builder
• Bold Grid
• Divi
• Custom Field Plugins
{ Menus – More Menus }
• Adding new menus
• WP Dashboard
• Theme modification
• WP Dashboard
• Appearance -> Menu
• New Menu
• Add Menu Items
{ Menus – More Menus }
• Theme Function File
– Create Menu Definition
• Creates Menu Position
• Relevant Theme File
– Header.php
– Footer.php
– Sidebar.php, sidebar-_____.php
– Page.php
– Etc…
{ Menus – More Menus }
• Add wp_nav_menu() function call
wp_nav_menu( array(
'menu' => 'Top Navigation',
'sub_menu' => true
) );
{ Thanks! }
Joe Querin
www.joequerin.com
@joequerin
joecue
joecue

Contenu connexe

Tendances

Taking WordPress as a CMS, to the Limit
Taking WordPress as a CMS, to the LimitTaking WordPress as a CMS, to the Limit
Taking WordPress as a CMS, to the Limit
Josh Guffey
 
Wp nhcc portfolio
Wp nhcc portfolioWp nhcc portfolio
Wp nhcc portfolio
gregorvios
 
Anatomy and Architecture of a WordPress Theme
Anatomy and Architecture of a WordPress ThemeAnatomy and Architecture of a WordPress Theme
Anatomy and Architecture of a WordPress Theme
Julie Kuehl
 

Tendances (20)

Word press 101
Word press 101Word press 101
Word press 101
 
Taking WordPress as a CMS, to the Limit
Taking WordPress as a CMS, to the LimitTaking WordPress as a CMS, to the Limit
Taking WordPress as a CMS, to the Limit
 
WordPress Themes and Plugins
WordPress Themes and PluginsWordPress Themes and Plugins
WordPress Themes and Plugins
 
Websites With Wordpress
Websites With WordpressWebsites With Wordpress
Websites With Wordpress
 
Newspapers with WordPress
Newspapers with WordPressNewspapers with WordPress
Newspapers with WordPress
 
Wordpress Presentation
Wordpress Presentation Wordpress Presentation
Wordpress Presentation
 
WordPress Beginner Track
WordPress Beginner TrackWordPress Beginner Track
WordPress Beginner Track
 
Choosing the Right WordPress Theme
Choosing the Right WordPress ThemeChoosing the Right WordPress Theme
Choosing the Right WordPress Theme
 
WordPress plugins
WordPress pluginsWordPress plugins
WordPress plugins
 
Wordpress.com
Wordpress.comWordpress.com
Wordpress.com
 
How to create a WordPress Site
How to create a WordPress Site How to create a WordPress Site
How to create a WordPress Site
 
Keeping Your Themes and Plugins Organized.
Keeping Your Themes and Plugins Organized.Keeping Your Themes and Plugins Organized.
Keeping Your Themes and Plugins Organized.
 
Wordpress beyond blogging
Wordpress beyond bloggingWordpress beyond blogging
Wordpress beyond blogging
 
PluginBasicsWCNYC2014
PluginBasicsWCNYC2014PluginBasicsWCNYC2014
PluginBasicsWCNYC2014
 
Wp nhcc portfolio
Wp nhcc portfolioWp nhcc portfolio
Wp nhcc portfolio
 
Equity WordPress framework with Chad and Dave
Equity WordPress framework with Chad and DaveEquity WordPress framework with Chad and Dave
Equity WordPress framework with Chad and Dave
 
Anatomy and Architecture of a WordPress Theme
Anatomy and Architecture of a WordPress ThemeAnatomy and Architecture of a WordPress Theme
Anatomy and Architecture of a WordPress Theme
 
What Is A Blog?
What Is A Blog?What Is A Blog?
What Is A Blog?
 
Web 101 intro to html
Web 101  intro to htmlWeb 101  intro to html
Web 101 intro to html
 
WordPress 101 less than an hour
WordPress 101 less than an hourWordPress 101 less than an hour
WordPress 101 less than an hour
 

Similaire à WP 101 - Custom Fields & Post Types

The WordPress University 2012
The WordPress University 2012The WordPress University 2012
The WordPress University 2012
Stephanie Leary
 
Open Source CMS Playroom
Open Source CMS PlayroomOpen Source CMS Playroom
Open Source CMS Playroom
librarywebchic
 
Stepping Into Custom Post Types
Stepping Into Custom Post TypesStepping Into Custom Post Types
Stepping Into Custom Post Types
K.Adam White
 
How to get your theme in WordPress
How to get your theme in WordPressHow to get your theme in WordPress
How to get your theme in WordPress
Nisha Singh
 
Custom Post Types in Depth at WordCamp Montreal
Custom Post Types in Depth at WordCamp MontrealCustom Post Types in Depth at WordCamp Montreal
Custom Post Types in Depth at WordCamp Montreal
Joey Kudish
 

Similaire à WP 101 - Custom Fields & Post Types (20)

WordCamp Kent 2019 - WP 101: Custom Post Type & Custom Fields
WordCamp Kent 2019 - WP 101: Custom Post Type & Custom FieldsWordCamp Kent 2019 - WP 101: Custom Post Type & Custom Fields
WordCamp Kent 2019 - WP 101: Custom Post Type & Custom Fields
 
WordPress 3 Custom Post Types
WordPress 3 Custom Post TypesWordPress 3 Custom Post Types
WordPress 3 Custom Post Types
 
WP 201 Custom Post Types - Custom Fields - WordCamp Columbus 2015
WP 201   Custom Post Types - Custom Fields - WordCamp Columbus 2015WP 201   Custom Post Types - Custom Fields - WordCamp Columbus 2015
WP 201 Custom Post Types - Custom Fields - WordCamp Columbus 2015
 
Custom post types - WordPress
Custom post types - WordPressCustom post types - WordPress
Custom post types - WordPress
 
WordPress A CMS for Beginners, Geeks and Those In-Between
WordPress A CMS for Beginners, Geeks and Those In-BetweenWordPress A CMS for Beginners, Geeks and Those In-Between
WordPress A CMS for Beginners, Geeks and Those In-Between
 
The WordPress University 2012
The WordPress University 2012The WordPress University 2012
The WordPress University 2012
 
Starting WordPress Theme Review
Starting WordPress Theme ReviewStarting WordPress Theme Review
Starting WordPress Theme Review
 
Open Source CMS Playroom
Open Source CMS PlayroomOpen Source CMS Playroom
Open Source CMS Playroom
 
Slides 3 - Wordpress Networks Sites
Slides 3 - Wordpress Networks SitesSlides 3 - Wordpress Networks Sites
Slides 3 - Wordpress Networks Sites
 
WordPress Complete Tutorial
WordPress Complete TutorialWordPress Complete Tutorial
WordPress Complete Tutorial
 
Stepping Into Custom Post Types
Stepping Into Custom Post TypesStepping Into Custom Post Types
Stepping Into Custom Post Types
 
Wordpress theme development
Wordpress theme developmentWordpress theme development
Wordpress theme development
 
WordPress Intermediate Workshop
WordPress Intermediate WorkshopWordPress Intermediate Workshop
WordPress Intermediate Workshop
 
MCC Web Design Workshop
MCC Web Design WorkshopMCC Web Design Workshop
MCC Web Design Workshop
 
WordPress custom posts types for structured content
WordPress custom posts types for structured contentWordPress custom posts types for structured content
WordPress custom posts types for structured content
 
Content-Driven WordPress Development - WordCamp Omaha 2014
Content-Driven WordPress Development - WordCamp Omaha 2014Content-Driven WordPress Development - WordCamp Omaha 2014
Content-Driven WordPress Development - WordCamp Omaha 2014
 
WordPress can do that?!
WordPress can do that?!WordPress can do that?!
WordPress can do that?!
 
Add Custom Post Types to Your WordPress Website
Add Custom Post Types to Your WordPress WebsiteAdd Custom Post Types to Your WordPress Website
Add Custom Post Types to Your WordPress Website
 
How to get your theme in WordPress
How to get your theme in WordPressHow to get your theme in WordPress
How to get your theme in WordPress
 
Custom Post Types in Depth at WordCamp Montreal
Custom Post Types in Depth at WordCamp MontrealCustom Post Types in Depth at WordCamp Montreal
Custom Post Types in Depth at WordCamp Montreal
 

Plus de Joe Querin

Theme development essentials columbus oh word camp 2012
Theme development essentials   columbus oh word camp 2012Theme development essentials   columbus oh word camp 2012
Theme development essentials columbus oh word camp 2012
Joe Querin
 

Plus de Joe Querin (8)

WordCamp Kent 2019 - WP 101: Guten.. What?
WordCamp Kent 2019 - WP 101: Guten.. What?WordCamp Kent 2019 - WP 101: Guten.. What?
WordCamp Kent 2019 - WP 101: Guten.. What?
 
WordCamp Kent 2019 - WP 101: Local Development - Themes and Plugins
WordCamp Kent 2019 - WP 101: Local Development - Themes and PluginsWordCamp Kent 2019 - WP 101: Local Development - Themes and Plugins
WordCamp Kent 2019 - WP 101: Local Development - Themes and Plugins
 
WordCamp Kent 2019 - WP 101: WordPress Basics
WordCamp Kent 2019 - WP 101: WordPress BasicsWordCamp Kent 2019 - WP 101: WordPress Basics
WordCamp Kent 2019 - WP 101: WordPress Basics
 
One Plugin to Rule All Your Custom Code
One Plugin to Rule All Your Custom CodeOne Plugin to Rule All Your Custom Code
One Plugin to Rule All Your Custom Code
 
Building a WordPress Sandbox
Building a WordPress SandboxBuilding a WordPress Sandbox
Building a WordPress Sandbox
 
Using WordPress as a web application platform
Using WordPress as a web application platformUsing WordPress as a web application platform
Using WordPress as a web application platform
 
Responsive Theme Workshop - WordCamp Columbus 2015
Responsive Theme Workshop - WordCamp Columbus 2015Responsive Theme Workshop - WordCamp Columbus 2015
Responsive Theme Workshop - WordCamp Columbus 2015
 
Theme development essentials columbus oh word camp 2012
Theme development essentials   columbus oh word camp 2012Theme development essentials   columbus oh word camp 2012
Theme development essentials columbus oh word camp 2012
 

Dernier

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Dernier (20)

FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 

WP 101 - Custom Fields & Post Types

  • 1. WP 101: Custom Fields& Custom Post Types Joe Querin – www.joequerin.com WordCamp Kent - Online – May 31, 2020 @joequerin joecue joecue
  • 2. { Overview } • Custom Fields vs Custom Post Types • Ways to Customize WordPress • What is CSS? • Need more menus? • Questions
  • 3. { Custom Post Types } • WordPress stores all page and post data as a post type. • There are actually 5 core post types • Post – Blog Entry • Page – Static content • Attachment – Document, Image, Video, etc. • Revision – Version of a Post or Page • Menu – Navigation/Menu Item
  • 4. Example Scenario • Let’s say you have a food blog and you want to use a custom post type to display your recipes. • So you use the awesome code we just looked at, customized it to represent your menu offerings. Created categories for breakfast, lunch, dinner, appetizers, desserts.
  • 5. Example Scenario • You have populated your menu with all of your fantastic recipes. • Life is good!
  • 6. Example Scenario • Now let’s say 3 months or 6 months, or maybe even a whole year goes by, and everything is still good. • Then you find the ultimate theme, it’s great, it looks just like you want your website to look. • So you install it, then you activate it. • Then later that day or the next someone emails and asks where are your recipes, so you tell them to click on recipes, and they ask WHERE? I’m on your site and there are no recipes.
  • 7. Example Scenario • So you go to your site and check. Hmmm no menu…. • Then in 3…2…1.. You panic!
  • 8. { Custom Post Types } • WordPress allows you to create your own custom post type. • Allows you to format content in a particular way. • Recipes • Products (non-ecommerce) • Frequently Asked Questions • Etc.
  • 9. { Custom Post Types } function create_post_type() { register_post_type( 'acme_product', array( 'labels' => array( 'name' => __( 'Products' ), 'singular_name' => __( 'Product' ) ), 'public' => true, 'has_archive' => true, ) ); } add_action( 'init', 'create_post_type' ); Sample code from https://codex.wordpress.org/Post_Types
  • 10. { Custom Post Types } • Plugins – Custom Post Types UI • https://generatewp.com/
  • 11. { Custom Fields } • The codex defines a custom field as meta- data, that contains a key/value pair. • ????
  • 12. { Custom Fields } • I’ll admit, it’s pretty technical and confusing • If you keep reading the codex page though, you’ll see what a key/value pair is. • Key – the name of the meta-data • Value – the meta-data • Example: – Key: Currently Reading – Value: Calvin and Hobbes
  • 13. { Custom Fields } • What can you do with custom fields? • Announcement features on your website • First create a custom post type to handle the announcement content – Title – Description – Photo • How about an announcement start date?
  • 14. { Custom Fields } • Create a custom field – Start Date – built in scheduling of Post – Display End Date – Importance • Using some PHP logic we can display the content we can make the post automatically display based upon the server’s date as well as when to stop.
  • 15. { Custom Fields } • Using similar PHP logic, we can even change the CSS class or ID of the containing element to make the announcement appear different.
  • 16. { Customize WP } • WordPress Customizer • Header Image • Site Title / Tagline • Colors • Additional CSS • Jetpack Plugin • Additional CSS option
  • 17. { Customize WP } • Page Builders • Gutenberg • Beaver Builder • Bold Grid • Divi • Custom Field Plugins
  • 18. { Menus – More Menus } • Adding new menus • WP Dashboard • Theme modification • WP Dashboard • Appearance -> Menu • New Menu • Add Menu Items
  • 19. { Menus – More Menus } • Theme Function File – Create Menu Definition • Creates Menu Position • Relevant Theme File – Header.php – Footer.php – Sidebar.php, sidebar-_____.php – Page.php – Etc…
  • 20. { Menus – More Menus } • Add wp_nav_menu() function call wp_nav_menu( array( 'menu' => 'Top Navigation', 'sub_menu' => true ) );
  • 21. { Thanks! } Joe Querin www.joequerin.com @joequerin joecue joecue