SlideShare a Scribd company logo
1 of 38
Download to read offline
Strawberry Custom
Fields Forever
!
Matt Banks
!
@mattbanks
photo credit: Sheri Bigelow, @designsimply
talk title credit: Damon Cook, @dcook
What are Custom Fields and
Meta boxes?
• Custom Fields allow you to attach additional
information (metadata) to a post, page, custom
post type, etc
• http://codex.wordpress.org/Custom_Fields
• Meta boxes are for separating and grouping
your Custom Fields into logical panels in the
post/page editor screen
Custom Fields
Meta boxes
Adding Custom Fields and Meta
boxes using Core functions
Add the Meta Box
add_meta_box(

$id,

$title,

$callback,

$post_type,

$context,

$priority,

$callback_args

);
Adding Custom Fields and Meta
boxes using Core functions
Create a Nonce and render the Meta Box via
callback function
wp_nonce_field(

'myplugin_meta_box',

'myplugin_meta_box_nonce'

);
Adding Custom Fields and Meta
boxes using Core functions
Verify the nonce, sanitize the data and update the Post Meta
sanitize_text_field(

$_POST['myplugin_new_field']

);
update_post_meta(

$post_id,

'_my_meta_value_key',

$my_data

);
Displaying Custom Field
data in your Theme
get_post_meta(

$post_id,

$key,

$single

);
$key_1_value = get_post_meta(
get_the_ID(), 'key_1', true );
http://codex.wordpress.org/Function_Reference/
get_post_meta
Playing Nice with the

New REST API
• Protected meta (prefixed with _) needs authorization to be
accessed by the API. Gets hooked to ‘init’ or ‘plugins_loaded’
!
register_meta(
$meta_type,
$meta_key,
$sanitize_callback,

$auth_callback = null
);
!
register_meta( 'post', '_my_meta_key',
'', '__return_true' );
Adding Custom Fields and Meta
boxes using Core functions
Demo
Adding Custom Fields and Meta
boxes using Core functions
Full code examples in Codex:
http://codex.wordpress.org/Function_Reference/
add_meta_box#Procedural

http://codex.wordpress.org/Function_Reference/
add_meta_box#Class
Is there something easier?
Yes!
photo credit: Sheri Bigelow
With a Little Help From My Friends
!
Plugins to create Custom Fields and Meta boxes
• Advanced Custom Fields (ACF)
• Custom Field Suite (CFS)
• Pods
• Custom Metaboxes and Fields
Advanced Custom Fields
(ACF)
http://www.advancedcustomfields.com/
Advanced Custom Fields
(ACF)
• Output data into your theme using:



the_field( 'your_field_name' );
Advanced Custom Fields
(ACF)
• Multiple field types
• Easy to use
• Premium add-ons (changing in version 5)
Custom Field Suite (CFS)
https://uproot.us
Custom Field Suite (CFS)
• Output data into your theme using:
!
$cfs->get(
$field_name,
$post_id,
$options
);
Custom Field Suite (CFS)
• Includes loop field types in free version
• Easy to use
• Great documentation
Custom Field Suite (CFS)
Demo
Pods
http://pods.io
Pods
• Output data multiple ways into your theme:
!
pods_field_display( $pod, $id,
$name, $single);
!
pods_image( $image, $size,
$default, $attributes, $force );
• Custom Pods loops, templates, pages
Pods
• Extremely powerful!
• Creates Custom Post Types and Taxonomies as well
as Custom Fields
• Able to extend Users, Comments, etc
• More complex than other plugins/solutions
• No loop fields (coming in v3.0)
• No meta box management (coming in v3.0)
Custom Metaboxes and
Fields
https://github.com/WebDevStudios/Custom-
Metaboxes-and-Fields-for-WordPress
Custom Metaboxes and
Fields
• Framework to create meta boxes and fields in
code
• Can be embedded in custom plugins
• Uses native WordPress functions for display
get_post_meta( $post_id, $key,
$single );
Custom Metaboxes and
Fields
• Extensive list of available post types
• Active development
• Extendible
Custom Metaboxes and
Fields
Demo
So, what’s the best
choice?
Well, it Depends…
• Plugins like ACF, CFS and Pods are the easiest
solution for adding data for most sites
• Custom Metaboxes and Fields and Core
functions are better for custom plugins, building
web apps with WordPress
Can we help Core?
Metadata UI API
Being built as a Feature Plugin
Metadata UI API
• A work in progress
• API to add fields and forms (meta boxes) to posts, pages,
custom post types. In the future, plans to add forms and
fields to options, users, comments, taxonomy terms,
media, etc.
• Any plugin using forms will be able to interface with the
API to display them, both on the back-end and public
forms
• Make Core easier for creating custom fields and meta
boxes for developers
Metadata UI API Example
Register new Form (meta box). User, Option
Group, Comment Forms planned for later.
!
register_post_form(
$form_name,
$post_type,
$form_args
);
Metadata UI API Example
Add Fields to Post Type. Fields can be inside a
Form (meta box) or in the editor at any point.
!
register_post_field(
$field_name,
$post_type,
$field_args
);
Metadata UI API
• UI/UX in progress for displaying custom fields
and meta boxes on post type edit screens
• Plugin authors will be able to extend field types,
HTML templates, form types, etc.
Come Together
• You can help!
• Follow along with the development on Github



https://github.com/wordpress-metadata/
metadata-ui-api
• Weekly meetings on IRC in

#wordpress-core-plugins Friday’s at 2pm ET
Hello, Goodbye
!
Thank You!
If you have any questions, let me know!
!
matt@collectivthkg.com
!
Twitter: @mattbanks
!
Skype: mattbanks-14
!
!
https://github.com/mattbanks/strawberry-custom-fields-forever

More Related Content

Viewers also liked

Viewers also liked (15)

Giant Pandas
Giant PandasGiant Pandas
Giant Pandas
 
Novedades junio 2014
Novedades junio 2014Novedades junio 2014
Novedades junio 2014
 
Shakib Al Hasan Photos
Shakib Al Hasan PhotosShakib Al Hasan Photos
Shakib Al Hasan Photos
 
Novedades mayo 2015
Novedades mayo 2015Novedades mayo 2015
Novedades mayo 2015
 
Novedades noviembre2015
Novedades noviembre2015Novedades noviembre2015
Novedades noviembre2015
 
Radware state of_the_union_report_winter_2013-14
Radware state of_the_union_report_winter_2013-14Radware state of_the_union_report_winter_2013-14
Radware state of_the_union_report_winter_2013-14
 
Novedades septiembre 2015
Novedades septiembre 2015Novedades septiembre 2015
Novedades septiembre 2015
 
Novedades diciembre 2015
Novedades diciembre 2015Novedades diciembre 2015
Novedades diciembre 2015
 
Mailing Services Price Changes
Mailing Services Price ChangesMailing Services Price Changes
Mailing Services Price Changes
 
ISOC Panel at IETF 90 - Internet Security and Privacy: Ten years later
ISOC Panel at IETF 90 - Internet Security and Privacy: Ten years laterISOC Panel at IETF 90 - Internet Security and Privacy: Ten years later
ISOC Panel at IETF 90 - Internet Security and Privacy: Ten years later
 
Il Sisma del 2012 nella Bassa Modenese: il ruolo del MMG
Il Sisma del 2012 nella Bassa Modenese: il ruolo del MMGIl Sisma del 2012 nella Bassa Modenese: il ruolo del MMG
Il Sisma del 2012 nella Bassa Modenese: il ruolo del MMG
 
Novedades enero 2016
Novedades enero 2016Novedades enero 2016
Novedades enero 2016
 
Novedades octubre 2015
Novedades octubre 2015Novedades octubre 2015
Novedades octubre 2015
 
Formazione ed implementazione dell'EBM con i social network. Risultati di un ...
Formazione ed implementazione dell'EBM con i social network. Risultati di un ...Formazione ed implementazione dell'EBM con i social network. Risultati di un ...
Formazione ed implementazione dell'EBM con i social network. Risultati di un ...
 
Novedades marzo 2016
Novedades marzo 2016Novedades marzo 2016
Novedades marzo 2016
 

Recently uploaded

My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 

Recently uploaded (20)

My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 

Strawberry Custom Fields Forever - WordPress Metadata and Custom Fields

  • 2. photo credit: Sheri Bigelow, @designsimply talk title credit: Damon Cook, @dcook
  • 3. What are Custom Fields and Meta boxes? • Custom Fields allow you to attach additional information (metadata) to a post, page, custom post type, etc • http://codex.wordpress.org/Custom_Fields • Meta boxes are for separating and grouping your Custom Fields into logical panels in the post/page editor screen
  • 6. Adding Custom Fields and Meta boxes using Core functions Add the Meta Box add_meta_box(
 $id,
 $title,
 $callback,
 $post_type,
 $context,
 $priority,
 $callback_args
 );
  • 7. Adding Custom Fields and Meta boxes using Core functions Create a Nonce and render the Meta Box via callback function wp_nonce_field(
 'myplugin_meta_box',
 'myplugin_meta_box_nonce'
 );
  • 8. Adding Custom Fields and Meta boxes using Core functions Verify the nonce, sanitize the data and update the Post Meta sanitize_text_field(
 $_POST['myplugin_new_field']
 ); update_post_meta(
 $post_id,
 '_my_meta_value_key',
 $my_data
 );
  • 9. Displaying Custom Field data in your Theme get_post_meta(
 $post_id,
 $key,
 $single
 ); $key_1_value = get_post_meta( get_the_ID(), 'key_1', true ); http://codex.wordpress.org/Function_Reference/ get_post_meta
  • 10. Playing Nice with the
 New REST API • Protected meta (prefixed with _) needs authorization to be accessed by the API. Gets hooked to ‘init’ or ‘plugins_loaded’ ! register_meta( $meta_type, $meta_key, $sanitize_callback,
 $auth_callback = null ); ! register_meta( 'post', '_my_meta_key', '', '__return_true' );
  • 11. Adding Custom Fields and Meta boxes using Core functions Demo
  • 12. Adding Custom Fields and Meta boxes using Core functions Full code examples in Codex: http://codex.wordpress.org/Function_Reference/ add_meta_box#Procedural
 http://codex.wordpress.org/Function_Reference/ add_meta_box#Class
  • 13. Is there something easier? Yes! photo credit: Sheri Bigelow
  • 14. With a Little Help From My Friends ! Plugins to create Custom Fields and Meta boxes • Advanced Custom Fields (ACF) • Custom Field Suite (CFS) • Pods • Custom Metaboxes and Fields
  • 16. Advanced Custom Fields (ACF) • Output data into your theme using:
 
 the_field( 'your_field_name' );
  • 17. Advanced Custom Fields (ACF) • Multiple field types • Easy to use • Premium add-ons (changing in version 5)
  • 18. Custom Field Suite (CFS) https://uproot.us
  • 19. Custom Field Suite (CFS) • Output data into your theme using: ! $cfs->get( $field_name, $post_id, $options );
  • 20. Custom Field Suite (CFS) • Includes loop field types in free version • Easy to use • Great documentation
  • 21. Custom Field Suite (CFS) Demo
  • 23. Pods • Output data multiple ways into your theme: ! pods_field_display( $pod, $id, $name, $single); ! pods_image( $image, $size, $default, $attributes, $force ); • Custom Pods loops, templates, pages
  • 24. Pods • Extremely powerful! • Creates Custom Post Types and Taxonomies as well as Custom Fields • Able to extend Users, Comments, etc • More complex than other plugins/solutions • No loop fields (coming in v3.0) • No meta box management (coming in v3.0)
  • 26. Custom Metaboxes and Fields • Framework to create meta boxes and fields in code • Can be embedded in custom plugins • Uses native WordPress functions for display get_post_meta( $post_id, $key, $single );
  • 27. Custom Metaboxes and Fields • Extensive list of available post types • Active development • Extendible
  • 29. So, what’s the best choice?
  • 30. Well, it Depends… • Plugins like ACF, CFS and Pods are the easiest solution for adding data for most sites • Custom Metaboxes and Fields and Core functions are better for custom plugins, building web apps with WordPress
  • 31. Can we help Core?
  • 32. Metadata UI API Being built as a Feature Plugin
  • 33. Metadata UI API • A work in progress • API to add fields and forms (meta boxes) to posts, pages, custom post types. In the future, plans to add forms and fields to options, users, comments, taxonomy terms, media, etc. • Any plugin using forms will be able to interface with the API to display them, both on the back-end and public forms • Make Core easier for creating custom fields and meta boxes for developers
  • 34. Metadata UI API Example Register new Form (meta box). User, Option Group, Comment Forms planned for later. ! register_post_form( $form_name, $post_type, $form_args );
  • 35. Metadata UI API Example Add Fields to Post Type. Fields can be inside a Form (meta box) or in the editor at any point. ! register_post_field( $field_name, $post_type, $field_args );
  • 36. Metadata UI API • UI/UX in progress for displaying custom fields and meta boxes on post type edit screens • Plugin authors will be able to extend field types, HTML templates, form types, etc.
  • 37. Come Together • You can help! • Follow along with the development on Github
 
 https://github.com/wordpress-metadata/ metadata-ui-api • Weekly meetings on IRC in
 #wordpress-core-plugins Friday’s at 2pm ET
  • 38. Hello, Goodbye ! Thank You! If you have any questions, let me know! ! matt@collectivthkg.com ! Twitter: @mattbanks ! Skype: mattbanks-14 ! ! https://github.com/mattbanks/strawberry-custom-fields-forever