SlideShare a Scribd company logo
1 of 23
Download to read offline
ADVANCINGYOUR CUSTOM FIELDS
Troy Chaplin	

WordCamp Ottawa 2014
WHAT ARE CUSTOM FIELDS
• Meta data fields that store arbitrary information	

• Meta data is handled with key and value pairs	

• Same key can be used multiple times on same post	

• Advanced functionality include dates for post expiration, or yes / no
values to show or hide elements on a post
ENHANCING CUSTOM FIELDS
• Core custom field interface is not user friendly or intuitive	

• Confusing to non technical users	

• Not immediately apparent what they are used for	

• Require users to know exact key naming convention	

• Don’t fit into a seamless workflow
ADVANCED CUSTOM FIELDS
• Powerful plugin to create groups of custom
fields	

• Over 20 field types	

• Easy integration for developer	

• Intuitive custom field interfaces for content
editors	

• Free and Premium add-ons for additional
functionality	

• Conditional logic	

• Set fields to be required to ensure data input
GETTING STARTED
• Similar feel to creating a post — uses a
custom post type	

• Title area to easily identify groups in a
larger list	

• Specify where groups will be used (posts,
pages, custom post types, categories,
taxonomies, templates, parents, and more)	

• Options to set order of appearance,
position, style	

• Simple way to hide other default items
BASIC FIELDS
• Text: open ended field that accepts
anything the user wishes to use	

• Text Area: basic paragraph editor (this
one has a character limit applied)	

• Number: accepts only numerical values	

• Email & Password: open ended field
that accepts any form of text
BUILDING BASIC FIELDS
Getting the meta data
<?php the_field(‘field_name'); ?>	

$textName = get_field(‘field_name');	

Example
<article>	

	

 <h1><?php the_field('text'); ?></h1>	

	

 <p><?php the_field('text_area'); ?></p>	

	

 <ul>	

	

 	

 <li><?php the_field('number'); ?></li>	

	

 	

 <li><?php the_field('email'); ?></li>	

	

 	

 <li><?php the_field('password'); ?></li>	

	

 </ul>	

</article>
CONTENT FIELDS
• Text Area with WYSIWYG: full
content editor with full or basic tool
options and media uploader	

• Image and File: upload and attach
images or files	

• Image and files can be configured to
return values of object, URL or ID
BUILDING CONTENT FIELDS
<article>	

	

 <?php the_field('text_area'); ?>	

	

 <img src="<?php the_field(‘image’); ?>"/>	

	

 <p><a href="<?php the_field('file'); ?>">Download File</a></p>	

</article>	

Images by ID
$image = get_field('image');	

$size = 'full'; // (thumbnail, medium, large, full or custom size)	

<?php wp_get_attachment_image( $image, $size ); ?>
BUILDING CONTENT FIELDS
Images by Post Object
<?php 	

	

 $image = get_field('image');	

	

 if( !empty($image) ): 	

	

 $url = $image['url'];	

 	

 $alt = $image['alt'];	

 	

 	

 $size = 'thumbnail';	

	

 $title = $image['title'];	

 	

 $caption = $image['caption'];	

 	

 $thumb = $image['sizes'][ $size ];	

?>	

	

 <?php if( $caption ): ?>	

	

 	

 <div class=“wp-caption">	

	

 <?php endif; ?>	

	

 	

 <img src="<?php echo $thumb; ?>" alt="<?php echo $alt; ?>" />	

	

 <?php if( $caption ): ?>	

	

 	

 	

 <p class="wp-caption-text"><?php echo $caption; ?></p>	

	

 	

 </div> // Closes wp-caption div	

	

 <?php endif; ?>	

<?php endif; ?>
CHOICE FIELDS
• Select: a drop down list of options for
user to select	

• Checkbox: a series of options where
users can select one or more items	

• Radio: a series of options where users
can select only one item at a time	

• True / False: a statement that users can
select to be true
BUILDING CHOICE FIELDS
Select or Checkbox Fields - Single Value
<?php the_field('field_name'); ?>	

Select or Checkbox Fields - Multiple Values
<?php echo implode(', ', get_field('field_name')); ?>	

True / False
if( get_field('field_name') ) {	

echo "do something";	

} else {	

echo "do something else";	

}
RELATION FIELDS
• Page Link: a drop down list of pages,
posts or custom post types, limited to
retrieving URL	

• Post Object: same as page link, can
also retrieve URL, title and meta data	

• Relationship: share data between
multiple posts through relationships	

• Taxonomy: a list of categories, tags or
taxonomies to select	

• User: a drop down list of core roles
BUILDING RELATION FIELDS
Page Link
<a href="<?php the_field('page_link'); ?>">Read this!</a>	

Post Object (Single)
<?php	

	

 $post_object = get_field('post_object');	

	

 if( $post_object ): 	

	

 	

 $post = $post_object;	

	

 	

 setup_postdata( $post ); 	

?>	

	

 <div>	

	

 	

 <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>	

	

 	

 <span>Post Object Custom Field: <?php the_field('field_name'); ?></span>	

	

 </div>	

	

 <?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly ?>	

<?php endif; ?>
BUILDING RELATION FIELDS
Basic loop (with setup_postdata)
<?php	

	

 $posts = get_field(‘relationship_field_name');	

	

 if( $posts ): 	

?>	

	

 <ul>	

	

 <?php foreach( $posts as $post): // variable must be called $post (IMPORTANT) ?>	

	

 	

 <?php setup_postdata($post); ?>	

	

 	

 <li>	

	

 	

 	

 <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>	

	

 	

 	

 <span>Custom field from $post: <?php the_field('author'); ?></span>	

	

 	

 </li>	

	

 <?php endforeach; ?>	

	

 </ul>	

	

 <?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly ?>	

<?php endif; ?>
OTHER FIELDS
• Tabs: group fields inside tabs	

• Google Maps: an interactive map with the
ability to search an address and place a
marker	

• Date Picker: a jQuery date selection pop up	

• Color Picker: a jQuery color selection pop
up	

• Messages: a place for you to provide
additional instructions or notes that not have
an user input
ADD-ONS
Premium
• Flexible Content
Field	

• Gallery Field	

• Repeater Field	

• Options Page
Freebies
• PayPal Field	

• Text Limiter	

• WordPress
WYSIWYG	

• Gravity Forms Field	

• Date andTime Picker	

• Contact Form 7 Field	

• Taxonomy Field
– Steve Jobs
“Simple can be harder than complex:You have to
work hard to get your thinking clean to make it simple.
But it’s worth it in the end because once you get
there, you can move mountains.”
THANKS FOR COMING OUT!	

ANY QUESTIONS?
@troychaplin	

troychaplin.ca

More Related Content

What's hot

Parsing strange v3
Parsing strange v3Parsing strange v3
Parsing strange v3
Hal Stern
 
Drupal 8 templating with twig
Drupal 8 templating with twigDrupal 8 templating with twig
Drupal 8 templating with twig
Taras Omelianenko
 
Drupal 8: Theming
Drupal 8: ThemingDrupal 8: Theming
Drupal 8: Theming
drubb
 

What's hot (20)

Parsing strange v3
Parsing strange v3Parsing strange v3
Parsing strange v3
 
Drupal 8 templating with twig
Drupal 8 templating with twigDrupal 8 templating with twig
Drupal 8 templating with twig
 
Avoiding Pitfalls with Internationalization & Localization
Avoiding Pitfalls with Internationalization & LocalizationAvoiding Pitfalls with Internationalization & Localization
Avoiding Pitfalls with Internationalization & Localization
 
Drupal 8 introduction to theming
Drupal 8  introduction to themingDrupal 8  introduction to theming
Drupal 8 introduction to theming
 
Html and Xhtml
Html and XhtmlHtml and Xhtml
Html and Xhtml
 
8 things to know about theming in drupal 8
8 things to know about theming in drupal 88 things to know about theming in drupal 8
8 things to know about theming in drupal 8
 
Writing a WordPress Theme - HighEdWeb 2013 #WRK2
Writing a WordPress Theme - HighEdWeb 2013 #WRK2Writing a WordPress Theme - HighEdWeb 2013 #WRK2
Writing a WordPress Theme - HighEdWeb 2013 #WRK2
 
NewBCamp09: Turning your design into a WordPress Theme
NewBCamp09: Turning your design into a WordPress ThemeNewBCamp09: Turning your design into a WordPress Theme
NewBCamp09: Turning your design into a WordPress Theme
 
6 global library function provided by open cart
6 global library function provided by open cart6 global library function provided by open cart
6 global library function provided by open cart
 
Wordpress theme development
Wordpress theme developmentWordpress theme development
Wordpress theme development
 
Drupal 8 theming deep dive
Drupal 8 theming deep diveDrupal 8 theming deep dive
Drupal 8 theming deep dive
 
Xhtml 2010
Xhtml 2010Xhtml 2010
Xhtml 2010
 
Doing more with LESS
Doing more with LESSDoing more with LESS
Doing more with LESS
 
WEB DEVELOPMENT
WEB DEVELOPMENTWEB DEVELOPMENT
WEB DEVELOPMENT
 
Css
CssCss
Css
 
Grok Drupal (7) Theming
Grok Drupal (7) ThemingGrok Drupal (7) Theming
Grok Drupal (7) Theming
 
Grok Drupal (7) Theming (presented at DrupalCon San Francisco)
Grok Drupal (7) Theming (presented at DrupalCon San Francisco)Grok Drupal (7) Theming (presented at DrupalCon San Francisco)
Grok Drupal (7) Theming (presented at DrupalCon San Francisco)
 
PHP - Introduction to PHP Fundamentals
PHP -  Introduction to PHP FundamentalsPHP -  Introduction to PHP Fundamentals
PHP - Introduction to PHP Fundamentals
 
One-hour Drupal 8 Theming
One-hour Drupal 8 ThemingOne-hour Drupal 8 Theming
One-hour Drupal 8 Theming
 
Drupal 8: Theming
Drupal 8: ThemingDrupal 8: Theming
Drupal 8: Theming
 

Viewers also liked

Rahul organizing
Rahul organizingRahul organizing
Rahul organizing
rkjn90
 
HR Answers-HR 101
HR Answers-HR 101HR Answers-HR 101
HR Answers-HR 101
Steve Lovig
 
Aspire Systems_CoE_Cloud Service Offerings
Aspire Systems_CoE_Cloud Service OfferingsAspire Systems_CoE_Cloud Service Offerings
Aspire Systems_CoE_Cloud Service Offerings
Ramani R
 

Viewers also liked (8)

Rahul organizing
Rahul organizingRahul organizing
Rahul organizing
 
Albumsitiolandia
AlbumsitiolandiaAlbumsitiolandia
Albumsitiolandia
 
Writing for the Web
Writing for the WebWriting for the Web
Writing for the Web
 
IT Communications and Rockstars
IT Communications and RockstarsIT Communications and Rockstars
IT Communications and Rockstars
 
HR Answers-HR 101
HR Answers-HR 101HR Answers-HR 101
HR Answers-HR 101
 
Aspire Systems_CoE_Cloud Service Offerings
Aspire Systems_CoE_Cloud Service OfferingsAspire Systems_CoE_Cloud Service Offerings
Aspire Systems_CoE_Cloud Service Offerings
 
The Six Highest Performing B2B Blog Post Formats
The Six Highest Performing B2B Blog Post FormatsThe Six Highest Performing B2B Blog Post Formats
The Six Highest Performing B2B Blog Post Formats
 
The Outcome Economy
The Outcome EconomyThe Outcome Economy
The Outcome Economy
 

Similar to Advancing Your Custom Fields - WordCamp 2014

The WordPress University 2012
The WordPress University 2012The WordPress University 2012
The WordPress University 2012
Stephanie Leary
 
Word press templates
Word press templatesWord press templates
Word press templates
Dan Phiffer
 
Parsing strange v2
Parsing strange v2Parsing strange v2
Parsing strange v2
Hal Stern
 

Similar to Advancing Your Custom Fields - WordCamp 2014 (20)

The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017
 
The Way to Theme Enlightenment
The Way to Theme EnlightenmentThe Way to Theme Enlightenment
The Way to Theme Enlightenment
 
Introduction to Advanced Custom Fields
Introduction to Advanced Custom FieldsIntroduction to Advanced Custom Fields
Introduction to Advanced Custom Fields
 
The WordPress University 2012
The WordPress University 2012The WordPress University 2012
The WordPress University 2012
 
Grok Drupal (7) Theming - 2011 Feb update
Grok Drupal (7) Theming - 2011 Feb updateGrok Drupal (7) Theming - 2011 Feb update
Grok Drupal (7) Theming - 2011 Feb update
 
presentation
presentationpresentation
presentation
 
Add-On Development: EE Expects that Every Developer will do his Duty
Add-On Development: EE Expects that Every Developer will do his DutyAdd-On Development: EE Expects that Every Developer will do his Duty
Add-On Development: EE Expects that Every Developer will do his Duty
 
Refactoring
RefactoringRefactoring
Refactoring
 
Add-On Development: EE Expects that Every Developer will do his Duty
Add-On Development: EE Expects that Every Developer will do his DutyAdd-On Development: EE Expects that Every Developer will do his Duty
Add-On Development: EE Expects that Every Developer will do his Duty
 
presentation
presentationpresentation
presentation
 
Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...
Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...
Don't Fear the Custom Theme: How to build a custom WordPress theme with only ...
 
Word press templates
Word press templatesWord press templates
Word press templates
 
Supercharging WordPress Development in 2018
Supercharging WordPress Development in 2018Supercharging WordPress Development in 2018
Supercharging WordPress Development in 2018
 
Parsing strange v2
Parsing strange v2Parsing strange v2
Parsing strange v2
 
WordPress Theming 101
WordPress Theming 101WordPress Theming 101
WordPress Theming 101
 
[WLDN] Supercharging word press development in 2018
[WLDN] Supercharging word press development in 2018[WLDN] Supercharging word press development in 2018
[WLDN] Supercharging word press development in 2018
 
PSD to WordPress
PSD to WordPressPSD to WordPress
PSD to WordPress
 
Carrington Core (2014)
Carrington Core (2014)Carrington Core (2014)
Carrington Core (2014)
 
Supercharging WordPress Development - Wordcamp Brighton 2019
Supercharging WordPress Development - Wordcamp Brighton 2019Supercharging WordPress Development - Wordcamp Brighton 2019
Supercharging WordPress Development - Wordcamp Brighton 2019
 
Phphacku iitd
Phphacku iitdPhphacku iitd
Phphacku iitd
 

Recently uploaded

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
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
 

Recently uploaded (20)

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...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
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
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
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
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
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
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
"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 ...
 
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
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 

Advancing Your Custom Fields - WordCamp 2014

  • 1. ADVANCINGYOUR CUSTOM FIELDS Troy Chaplin WordCamp Ottawa 2014
  • 2. WHAT ARE CUSTOM FIELDS • Meta data fields that store arbitrary information • Meta data is handled with key and value pairs • Same key can be used multiple times on same post • Advanced functionality include dates for post expiration, or yes / no values to show or hide elements on a post
  • 3. ENHANCING CUSTOM FIELDS • Core custom field interface is not user friendly or intuitive • Confusing to non technical users • Not immediately apparent what they are used for • Require users to know exact key naming convention • Don’t fit into a seamless workflow
  • 4. ADVANCED CUSTOM FIELDS • Powerful plugin to create groups of custom fields • Over 20 field types • Easy integration for developer • Intuitive custom field interfaces for content editors • Free and Premium add-ons for additional functionality • Conditional logic • Set fields to be required to ensure data input
  • 5. GETTING STARTED • Similar feel to creating a post — uses a custom post type • Title area to easily identify groups in a larger list • Specify where groups will be used (posts, pages, custom post types, categories, taxonomies, templates, parents, and more) • Options to set order of appearance, position, style • Simple way to hide other default items
  • 6. BASIC FIELDS • Text: open ended field that accepts anything the user wishes to use • Text Area: basic paragraph editor (this one has a character limit applied) • Number: accepts only numerical values • Email & Password: open ended field that accepts any form of text
  • 7. BUILDING BASIC FIELDS Getting the meta data <?php the_field(‘field_name'); ?> $textName = get_field(‘field_name'); Example <article> <h1><?php the_field('text'); ?></h1> <p><?php the_field('text_area'); ?></p> <ul> <li><?php the_field('number'); ?></li> <li><?php the_field('email'); ?></li> <li><?php the_field('password'); ?></li> </ul> </article>
  • 8. CONTENT FIELDS • Text Area with WYSIWYG: full content editor with full or basic tool options and media uploader • Image and File: upload and attach images or files • Image and files can be configured to return values of object, URL or ID
  • 9. BUILDING CONTENT FIELDS <article> <?php the_field('text_area'); ?> <img src="<?php the_field(‘image’); ?>"/> <p><a href="<?php the_field('file'); ?>">Download File</a></p> </article> Images by ID $image = get_field('image'); $size = 'full'; // (thumbnail, medium, large, full or custom size) <?php wp_get_attachment_image( $image, $size ); ?>
  • 10. BUILDING CONTENT FIELDS Images by Post Object <?php $image = get_field('image'); if( !empty($image) ): $url = $image['url']; $alt = $image['alt']; $size = 'thumbnail'; $title = $image['title']; $caption = $image['caption']; $thumb = $image['sizes'][ $size ]; ?> <?php if( $caption ): ?> <div class=“wp-caption"> <?php endif; ?> <img src="<?php echo $thumb; ?>" alt="<?php echo $alt; ?>" /> <?php if( $caption ): ?> <p class="wp-caption-text"><?php echo $caption; ?></p> </div> // Closes wp-caption div <?php endif; ?> <?php endif; ?>
  • 11. CHOICE FIELDS • Select: a drop down list of options for user to select • Checkbox: a series of options where users can select one or more items • Radio: a series of options where users can select only one item at a time • True / False: a statement that users can select to be true
  • 12. BUILDING CHOICE FIELDS Select or Checkbox Fields - Single Value <?php the_field('field_name'); ?> Select or Checkbox Fields - Multiple Values <?php echo implode(', ', get_field('field_name')); ?> True / False if( get_field('field_name') ) { echo "do something"; } else { echo "do something else"; }
  • 13. RELATION FIELDS • Page Link: a drop down list of pages, posts or custom post types, limited to retrieving URL • Post Object: same as page link, can also retrieve URL, title and meta data • Relationship: share data between multiple posts through relationships • Taxonomy: a list of categories, tags or taxonomies to select • User: a drop down list of core roles
  • 14. BUILDING RELATION FIELDS Page Link <a href="<?php the_field('page_link'); ?>">Read this!</a> Post Object (Single) <?php $post_object = get_field('post_object'); if( $post_object ): $post = $post_object; setup_postdata( $post ); ?> <div> <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3> <span>Post Object Custom Field: <?php the_field('field_name'); ?></span> </div> <?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly ?> <?php endif; ?>
  • 15. BUILDING RELATION FIELDS Basic loop (with setup_postdata) <?php $posts = get_field(‘relationship_field_name'); if( $posts ): ?> <ul> <?php foreach( $posts as $post): // variable must be called $post (IMPORTANT) ?> <?php setup_postdata($post); ?> <li> <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> <span>Custom field from $post: <?php the_field('author'); ?></span> </li> <?php endforeach; ?> </ul> <?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly ?> <?php endif; ?>
  • 16. OTHER FIELDS • Tabs: group fields inside tabs • Google Maps: an interactive map with the ability to search an address and place a marker • Date Picker: a jQuery date selection pop up • Color Picker: a jQuery color selection pop up • Messages: a place for you to provide additional instructions or notes that not have an user input
  • 17. ADD-ONS Premium • Flexible Content Field • Gallery Field • Repeater Field • Options Page Freebies • PayPal Field • Text Limiter • WordPress WYSIWYG • Gravity Forms Field • Date andTime Picker • Contact Form 7 Field • Taxonomy Field
  • 18. – Steve Jobs “Simple can be harder than complex:You have to work hard to get your thinking clean to make it simple. But it’s worth it in the end because once you get there, you can move mountains.”
  • 19.
  • 20.
  • 21.
  • 22.
  • 23. THANKS FOR COMING OUT! ANY QUESTIONS? @troychaplin troychaplin.ca