SlideShare a Scribd company logo
1 of 41
Download to read offline
WordPress Custom Fields:
Control your content presentation
by breaking out of the_content box
(An introductory prelude to Custom Post Types)

I’m Denise Williams and I can be found at @lettergrade.
What we will cover:

A

B

C

D

why
Customize

how to
Customize

plugins
for easy
fields

next steps

What can our
pages gain?

a case study add a friendly roadmap to
admin area
custom post
using page
templates and
types
custom fields
Custom Post Types! Why not TODAY ?

It’s kind of like building a whole car when you
could start by riding the bike you already have.
Factory photo by Roger Wollstadt (http://www.flickr.com/photos/24736216@N07/)
Bike photo from the LOC: LC-B2- 2463-13
Denise Williams
Project director and WordPress developer
at Odeler Services in Montréal.
Can be found at:
www.lettergrade.ca
@lettergrade
15 years working in publishing and marketing,
directing and production managing content
projects.
Started using WordPress in 2007, as the
backend for magazine websites.
A
Why Customize
A
why
Customize

Place contextual
information for
highest impact.
A
why
Customize

Case Study:

Designing
a catalogue
of films.
A
Why
Customize

Domino’s film pages require many distinct
content areas:
–film title
–release year
–language
–genre
–running time
–official site url
–description

–production credits
–list of awards
–media reviews
–press kit download
–trailer
–related news
–’More like this’
A
Why
Customize

How site content is made

This code can go in
index.php, single.php,
page.php, etc...
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>

				
	<h1><?php the_title(); ?></h1>
	 <?php the_content(); ?>
				
<?php endwhile; ?>
<?php else : ?>
<?php endif; ?>
B
how to
Customize

AIEEE!

We’ve overstuffed
the content field.
B
how to
Customize

Final
‘Film Page’
layout
B

Film Title

how to
Customize

Language

Running Time

Director

Link to Official Site

Release Year
Genre

Still Image

Film Poster

Production Credits

Film Description

Cast
Trailer
Awards Received

‘More like this’
Media Reviews
Film News

Press Kit Download
B
How to Customize
B
how to
Customize

Step 1

Create a page template with
custom design elements
<?php
/*
Template Name: Film Page
*/
?>
Step 2a

B

Plan your content areas

how to
Customize

film-title

language

running-time

director
offical-site

release-year
genre

still-image

film-poster

production-credits

film-description

cast
trailer
awards-received

more-like-this
media-reviews
film-news

press-kit
What exactly ARE custom fields?
“Key/Value Pairs”
Think of custom fields as:
– he ability to create your own post template tags.
t
(Make some room, the_content!)
– mpty buckets in which you can store any piece of
e
information that you might want to retrieve later.
B
how to
Customize

Step 2b

Add custom field data to pages

Make sure
Custom Fields
are checked
in your Screen
Options tab
See Custom
Fields appear
below the body
content field
B
how to
Customize
B
how to
Customize
B
how to
Customize

How site content is made

This code can go in
index.php, single.php,
page.php, etc...
?php if ( have_posts() ) : ?
?php while ( have_posts() ) : the_post(); ?

				
	h1?php the_title(); ?/h1
	 ?php the_content(); ?
				
?php endwhile; ?
?php else : ?
?php endif; ?
B
how to
Customize

How site content is made

This code can go in index.php,
single.php, page.php, etc...
?php if ( have_posts() ) : ?
?php while ( have_posts() ) : the_post(); ?

				
	 h1?php the_title(); ?/h1
	 ?php the_content(); ?
	
?php echo get_post_meta($post-ID,
'key-value', true); ?
B
how to
Customize

Step 3

Code custom fields into page
template
function that
retrieves your
data for you

the name of the
value you want
to retrieve

?php echo get_post_meta($post-ID, 'key-value', true); ?

outputs your
value

the ID of the
current post
or page

true = single value
false = array of
multiple values
B
how to
Customize

Step 3

Code custom fields into page
template

?php echo get_post_meta($post-ID, 'key-value', true); ?

Note: the key-value is the ONLY item we need to change!
?php echo get_post_meta($post-ID, 'film-director', true); ?
B
how to
Customize

HOORAY!
Our final film page
layout works.
Now, how can we
make it better and
more flexible?
Extra Tip!

B
how to
Customize

Add conditional code to hide or
display a whole content section

Before:
	

h4 class = creditsAwards/h4

	

?php echo get_post_meta($post-ID, 'film-awards', true); ?

	

div class = doubleline/div
Extra Tip!

B
how to
Customize

Add conditional code to hide or
display a whole content section

after:
?php
if ( get_post_meta($post-ID, 'film-awards', true) ) { ?
	

h4 class = creditsAwards/h4

	

div class = doubleline/div

	

?php echo get_post_meta($post-ID, 'film-awards', true); ?

?php } else { ?
?php } ?
Extra tip!

B

Add ‘else’ to publish default info
if no new value exists

how to
Customize

h4 class = creditsAwards/h4
div class = doubleline/div
?php
if ( get_post_meta($post-ID, 'film-awards', true) ) { ?
	

?php echo get_post_meta($post-ID, 'film-awards', true); ?

?php } else { ?
	

pNo awards yet. Please petition a href =

	

http://www.oscars.org/the Oscar committee/a./p

?php } ?
But what about posts?
The layout concepts are the same when adapting posts, but post
templates are not created the same way as page templates. The
difference is that the syntax for ‘single-{typename}.php is reserved
for Custom Post Types.
Options:

— dapt existing templates by adding custom code to
a
single.php, index.php, archive.php, and category.php
— dd conditional code to current template files, so certain
a
custom fields display for certain categories
— se one of the many post template plugins to
u
recognize and apply your post templates:
http://wordpress.org/plugins/search.php?q=post+template
C
Content Entry Plugins
Think about the backend your user will see.

Photo from the LOC: LC-B2- 2457-5
C
B
plugins
for easy
fields
C
B
plugins
for easy
fields

Advanced Custom Fields
C
B
plugins
for easy
fields

Create new sets of fields
C
B
plugins
for easy
fields

Assign a format for the type of field you
want to show
C
B
plugins
for easy
fields

You can add titles
and instructions
and rules to the
fields you’ve
chosen.

Plugin settings page
C
B
plugins
for easy
fields

You can add titles and instructions and rules
to the fields you’ve chosen.
Plugin settings page

Add/edit page screen
C
B
plugins
for easy
fields

Add/edit page screen
C
plugins
for easy
fields

Other Custom Fields plugins

Custom Fields
http://wordpress.org/plugins/custom-fields/

Developers Custom Fields
http://wordpress.org/plugins/developers-custom-fields/

Search for more plugins:
http://wordpress.org/plugins/search.php?q=custom+fields

Suggestions?
D
Next Steps
D
Next steps

Where do we go from here?

1. Start thinking endlessly about content presentation options.
2.  ook at lots of examples. I’ve started collecting some sites
L
from WP Showcase for you at this page on my blog (your
contributions are welcome!):
	http://blog.lettergrade.ca/custom-site-library/

3.  ave fun with it! Practice for a year. (Six months if you’re
H
really into it.)
4.  ombine all the elements you’ve practiced into planning
C
and building a Custom Post Type.
THANK YOU.
Questions?

I’m Denise Williams and I can be found at @lettergrade.

More Related Content

What's hot

Responsive Theme Workshop - WordCamp Columbus 2015
Responsive Theme Workshop - WordCamp Columbus 2015Responsive Theme Workshop - WordCamp Columbus 2015
Responsive Theme Workshop - WordCamp Columbus 2015Joe Querin
 
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 ...LinnAlexandra
 
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 2012Joe Querin
 
WordPress Theme Design - Rich Media Institute Workshop
WordPress Theme Design - Rich Media Institute WorkshopWordPress Theme Design - Rich Media Institute Workshop
WordPress Theme Design - Rich Media Institute WorkshopBrendan Sera-Shriar
 
WordPress 2.5 Overview - Rich Media Institute
WordPress 2.5 Overview - Rich Media InstituteWordPress 2.5 Overview - Rich Media Institute
WordPress 2.5 Overview - Rich Media InstituteBrendan Sera-Shriar
 
Build a WordPress theme from HTML5 template @ Telerik
Build a WordPress theme from HTML5 template @ TelerikBuild a WordPress theme from HTML5 template @ Telerik
Build a WordPress theme from HTML5 template @ TelerikMario Peshev
 
Advanced Custom Fields: Amazing Possibilities and Irritating Limitations
Advanced Custom Fields: Amazing Possibilities and Irritating LimitationsAdvanced Custom Fields: Amazing Possibilities and Irritating Limitations
Advanced Custom Fields: Amazing Possibilities and Irritating LimitationsEast Bay WordPress Meetup
 
Structured Data in WordPress
Structured Data in WordPressStructured Data in WordPress
Structured Data in WordPressrandyhoyt
 
Introduction to WordPress Theme Development
Introduction to WordPress Theme DevelopmentIntroduction to WordPress Theme Development
Introduction to WordPress Theme DevelopmentSitdhibong Laokok
 
Week 9 - Introduction to Child Themes
Week 9  - Introduction to Child ThemesWeek 9  - Introduction to Child Themes
Week 9 - Introduction to Child Themeshenri_makembe
 
Week 7 introduction to theme development
Week 7   introduction to theme developmentWeek 7   introduction to theme development
Week 7 introduction to theme developmenthenri_makembe
 
Week 11 - Hosting and Migration
Week 11 - Hosting and MigrationWeek 11 - Hosting and Migration
Week 11 - Hosting and Migrationhenri_makembe
 
Cms & wordpress theme development 2011
Cms & wordpress theme development 2011Cms & wordpress theme development 2011
Cms & wordpress theme development 2011Dave Wallace
 
Advanced Web Development
Advanced Web DevelopmentAdvanced Web Development
Advanced Web DevelopmentRobert J. Stein
 
Wordpress beyond blogging
Wordpress beyond bloggingWordpress beyond blogging
Wordpress beyond bloggingJulien Minguely
 
EECI2009 - From Design to Dynamic - Rapid ExpressionEngine Development
EECI2009 - From Design to Dynamic - Rapid ExpressionEngine DevelopmentEECI2009 - From Design to Dynamic - Rapid ExpressionEngine Development
EECI2009 - From Design to Dynamic - Rapid ExpressionEngine DevelopmentFortySeven Media
 
Extension developer secrets - How to make money with Joomla
Extension developer secrets - How to make money with JoomlaExtension developer secrets - How to make money with Joomla
Extension developer secrets - How to make money with JoomlaTim Plummer
 
Child Themes (WordCamp Dublin 2017) with notes
Child Themes (WordCamp Dublin 2017) with notesChild Themes (WordCamp Dublin 2017) with notes
Child Themes (WordCamp Dublin 2017) with notesDamien Carbery
 

What's hot (20)

Responsive Theme Workshop - WordCamp Columbus 2015
Responsive Theme Workshop - WordCamp Columbus 2015Responsive Theme Workshop - WordCamp Columbus 2015
Responsive Theme Workshop - WordCamp Columbus 2015
 
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 ...
 
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
 
WordPress Theme Design - Rich Media Institute Workshop
WordPress Theme Design - Rich Media Institute WorkshopWordPress Theme Design - Rich Media Institute Workshop
WordPress Theme Design - Rich Media Institute Workshop
 
WordPress 2.5 Overview - Rich Media Institute
WordPress 2.5 Overview - Rich Media InstituteWordPress 2.5 Overview - Rich Media Institute
WordPress 2.5 Overview - Rich Media Institute
 
Build a WordPress theme from HTML5 template @ Telerik
Build a WordPress theme from HTML5 template @ TelerikBuild a WordPress theme from HTML5 template @ Telerik
Build a WordPress theme from HTML5 template @ Telerik
 
Theming 101
Theming 101Theming 101
Theming 101
 
Advanced Custom Fields: Amazing Possibilities and Irritating Limitations
Advanced Custom Fields: Amazing Possibilities and Irritating LimitationsAdvanced Custom Fields: Amazing Possibilities and Irritating Limitations
Advanced Custom Fields: Amazing Possibilities and Irritating Limitations
 
Structured Data in WordPress
Structured Data in WordPressStructured Data in WordPress
Structured Data in WordPress
 
Introduction to WordPress Theme Development
Introduction to WordPress Theme DevelopmentIntroduction to WordPress Theme Development
Introduction to WordPress Theme Development
 
Week 9 - Introduction to Child Themes
Week 9  - Introduction to Child ThemesWeek 9  - Introduction to Child Themes
Week 9 - Introduction to Child Themes
 
Week 7 introduction to theme development
Week 7   introduction to theme developmentWeek 7   introduction to theme development
Week 7 introduction to theme development
 
Week 11 - Hosting and Migration
Week 11 - Hosting and MigrationWeek 11 - Hosting and Migration
Week 11 - Hosting and Migration
 
Cms & wordpress theme development 2011
Cms & wordpress theme development 2011Cms & wordpress theme development 2011
Cms & wordpress theme development 2011
 
Advanced Web Development
Advanced Web DevelopmentAdvanced Web Development
Advanced Web Development
 
Wordpress beyond blogging
Wordpress beyond bloggingWordpress beyond blogging
Wordpress beyond blogging
 
EECI2009 - From Design to Dynamic - Rapid ExpressionEngine Development
EECI2009 - From Design to Dynamic - Rapid ExpressionEngine DevelopmentEECI2009 - From Design to Dynamic - Rapid ExpressionEngine Development
EECI2009 - From Design to Dynamic - Rapid ExpressionEngine Development
 
Extension developer secrets - How to make money with Joomla
Extension developer secrets - How to make money with JoomlaExtension developer secrets - How to make money with Joomla
Extension developer secrets - How to make money with Joomla
 
Child Themes (WordCamp Dublin 2017) with notes
Child Themes (WordCamp Dublin 2017) with notesChild Themes (WordCamp Dublin 2017) with notes
Child Themes (WordCamp Dublin 2017) with notes
 
Rebrand WordPress Admin
Rebrand WordPress AdminRebrand WordPress Admin
Rebrand WordPress Admin
 

Similar to WordPress Custom Fields: Control your content presentation by breaking out of the_content box

So, You Wanna Dev? Join the Team! - WordCamp Raleigh 2017
So, You Wanna Dev? Join the Team! - WordCamp Raleigh 2017 So, You Wanna Dev? Join the Team! - WordCamp Raleigh 2017
So, You Wanna Dev? Join the Team! - WordCamp Raleigh 2017 Evan Mullins
 
Spencer Nash - Advanced Custom Fields
Spencer Nash - Advanced Custom FieldsSpencer Nash - Advanced Custom Fields
Spencer Nash - Advanced Custom Fieldsdominicj
 
Extending & Scaling | Dallas PHP
Extending & Scaling | Dallas PHPExtending & Scaling | Dallas PHP
Extending & Scaling | Dallas PHPrandyhoyt
 
Getting started with WordPress development
Getting started with WordPress developmentGetting started with WordPress development
Getting started with WordPress developmentSteve Mortiboy
 
PSD to WordPress
PSD to WordPressPSD to WordPress
PSD to WordPressNile Flores
 
WordCamp Asheville 2017 - So You Wanna Dev? Join the Team!
WordCamp Asheville 2017 - So You Wanna Dev? Join the Team!WordCamp Asheville 2017 - So You Wanna Dev? Join the Team!
WordCamp Asheville 2017 - So You Wanna Dev? Join the Team!Evan Mullins
 
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to DevelopmentWordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to DevelopmentEvan Mullins
 
Step by step guide for creating wordpress plugin
Step by step guide for creating wordpress pluginStep by step guide for creating wordpress plugin
Step by step guide for creating wordpress pluginMainak Goswami
 
Writing your own WordPress themes and plugins
Writing your own WordPress themes and pluginsWriting your own WordPress themes and plugins
Writing your own WordPress themes and pluginsStephanie Wells
 
Developing Branding Solutions for 2013
Developing Branding Solutions for 2013Developing Branding Solutions for 2013
Developing Branding Solutions for 2013Thomas Daly
 
Introduction to-concrete-5
Introduction to-concrete-5Introduction to-concrete-5
Introduction to-concrete-5Ketan Raval
 
Introduction to-concrete-5
Introduction to-concrete-5Introduction to-concrete-5
Introduction to-concrete-5ketanraval
 
Customizing WordPress Themes
Customizing WordPress ThemesCustomizing WordPress Themes
Customizing WordPress ThemesLaura Hartwig
 

Similar to WordPress Custom Fields: Control your content presentation by breaking out of the_content box (20)

So, You Wanna Dev? Join the Team! - WordCamp Raleigh 2017
So, You Wanna Dev? Join the Team! - WordCamp Raleigh 2017 So, You Wanna Dev? Join the Team! - WordCamp Raleigh 2017
So, You Wanna Dev? Join the Team! - WordCamp Raleigh 2017
 
Spencer Nash - Advanced Custom Fields
Spencer Nash - Advanced Custom FieldsSpencer Nash - Advanced Custom Fields
Spencer Nash - Advanced Custom Fields
 
Extending & Scaling | Dallas PHP
Extending & Scaling | Dallas PHPExtending & Scaling | Dallas PHP
Extending & Scaling | Dallas PHP
 
Getting started with WordPress development
Getting started with WordPress developmentGetting started with WordPress development
Getting started with WordPress development
 
W pthemes
W pthemesW pthemes
W pthemes
 
Faster WordPress Workflows
Faster WordPress WorkflowsFaster WordPress Workflows
Faster WordPress Workflows
 
PSD to WordPress
PSD to WordPressPSD to WordPress
PSD to WordPress
 
WordCamp Asheville 2017 - So You Wanna Dev? Join the Team!
WordCamp Asheville 2017 - So You Wanna Dev? Join the Team!WordCamp Asheville 2017 - So You Wanna Dev? Join the Team!
WordCamp Asheville 2017 - So You Wanna Dev? Join the Team!
 
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to DevelopmentWordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
 
Step by step guide for creating wordpress plugin
Step by step guide for creating wordpress pluginStep by step guide for creating wordpress plugin
Step by step guide for creating wordpress plugin
 
Writing your own WordPress themes and plugins
Writing your own WordPress themes and pluginsWriting your own WordPress themes and plugins
Writing your own WordPress themes and plugins
 
Custom Fields & Custom Metaboxes Overview
Custom Fields & Custom Metaboxes OverviewCustom Fields & Custom Metaboxes Overview
Custom Fields & Custom Metaboxes Overview
 
Developing Branding Solutions for 2013
Developing Branding Solutions for 2013Developing Branding Solutions for 2013
Developing Branding Solutions for 2013
 
Meet WordPress
Meet WordPressMeet WordPress
Meet WordPress
 
Internet Librarian Slides
Internet Librarian SlidesInternet Librarian Slides
Internet Librarian Slides
 
Introduction to-concrete-5
Introduction to-concrete-5Introduction to-concrete-5
Introduction to-concrete-5
 
Introduction to-concrete-5
Introduction to-concrete-5Introduction to-concrete-5
Introduction to-concrete-5
 
Customizing WordPress Themes
Customizing WordPress ThemesCustomizing WordPress Themes
Customizing WordPress Themes
 
Extending WordPress
Extending WordPressExtending WordPress
Extending WordPress
 
Test ss 1
Test ss 1Test ss 1
Test ss 1
 

Recently uploaded

WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
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 Takeoffsammart93
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
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.pptxRustici Software
 
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...apidays
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
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 businesspanagenda
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
"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 ...Zilliz
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
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 REVIEWERMadyBayot
 
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...Jeffrey Haguewood
 

Recently uploaded (20)

WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
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
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
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
 
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...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
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
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
"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 ...
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
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
 
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...
 

WordPress Custom Fields: Control your content presentation by breaking out of the_content box

  • 1. WordPress Custom Fields: Control your content presentation by breaking out of the_content box (An introductory prelude to Custom Post Types) I’m Denise Williams and I can be found at @lettergrade.
  • 2. What we will cover: A B C D why Customize how to Customize plugins for easy fields next steps What can our pages gain? a case study add a friendly roadmap to admin area custom post using page templates and types custom fields
  • 3. Custom Post Types! Why not TODAY ? It’s kind of like building a whole car when you could start by riding the bike you already have. Factory photo by Roger Wollstadt (http://www.flickr.com/photos/24736216@N07/) Bike photo from the LOC: LC-B2- 2463-13
  • 4. Denise Williams Project director and WordPress developer at Odeler Services in Montréal. Can be found at: www.lettergrade.ca @lettergrade 15 years working in publishing and marketing, directing and production managing content projects. Started using WordPress in 2007, as the backend for magazine websites.
  • 8. A Why Customize Domino’s film pages require many distinct content areas: –film title –release year –language –genre –running time –official site url –description –production credits –list of awards –media reviews –press kit download –trailer –related news –’More like this’
  • 9. A Why Customize How site content is made This code can go in index.php, single.php, page.php, etc... <?php if ( have_posts() ) : ?> <?php while ( have_posts() ) : the_post(); ?> <h1><?php the_title(); ?></h1> <?php the_content(); ?> <?php endwhile; ?> <?php else : ?> <?php endif; ?>
  • 12. B Film Title how to Customize Language Running Time Director Link to Official Site Release Year Genre Still Image Film Poster Production Credits Film Description Cast Trailer Awards Received ‘More like this’ Media Reviews Film News Press Kit Download
  • 14. B how to Customize Step 1 Create a page template with custom design elements <?php /* Template Name: Film Page */ ?>
  • 15. Step 2a B Plan your content areas how to Customize film-title language running-time director offical-site release-year genre still-image film-poster production-credits film-description cast trailer awards-received more-like-this media-reviews film-news press-kit
  • 16. What exactly ARE custom fields? “Key/Value Pairs” Think of custom fields as: – he ability to create your own post template tags. t (Make some room, the_content!) – mpty buckets in which you can store any piece of e information that you might want to retrieve later.
  • 17. B how to Customize Step 2b Add custom field data to pages Make sure Custom Fields are checked in your Screen Options tab See Custom Fields appear below the body content field
  • 20. B how to Customize How site content is made This code can go in index.php, single.php, page.php, etc... ?php if ( have_posts() ) : ? ?php while ( have_posts() ) : the_post(); ? h1?php the_title(); ?/h1 ?php the_content(); ? ?php endwhile; ? ?php else : ? ?php endif; ?
  • 21. B how to Customize How site content is made This code can go in index.php, single.php, page.php, etc... ?php if ( have_posts() ) : ? ?php while ( have_posts() ) : the_post(); ? h1?php the_title(); ?/h1 ?php the_content(); ? ?php echo get_post_meta($post-ID, 'key-value', true); ?
  • 22. B how to Customize Step 3 Code custom fields into page template function that retrieves your data for you the name of the value you want to retrieve ?php echo get_post_meta($post-ID, 'key-value', true); ? outputs your value the ID of the current post or page true = single value false = array of multiple values
  • 23. B how to Customize Step 3 Code custom fields into page template ?php echo get_post_meta($post-ID, 'key-value', true); ? Note: the key-value is the ONLY item we need to change! ?php echo get_post_meta($post-ID, 'film-director', true); ?
  • 24. B how to Customize HOORAY! Our final film page layout works. Now, how can we make it better and more flexible?
  • 25. Extra Tip! B how to Customize Add conditional code to hide or display a whole content section Before: h4 class = creditsAwards/h4 ?php echo get_post_meta($post-ID, 'film-awards', true); ? div class = doubleline/div
  • 26. Extra Tip! B how to Customize Add conditional code to hide or display a whole content section after: ?php if ( get_post_meta($post-ID, 'film-awards', true) ) { ? h4 class = creditsAwards/h4 div class = doubleline/div ?php echo get_post_meta($post-ID, 'film-awards', true); ? ?php } else { ? ?php } ?
  • 27. Extra tip! B Add ‘else’ to publish default info if no new value exists how to Customize h4 class = creditsAwards/h4 div class = doubleline/div ?php if ( get_post_meta($post-ID, 'film-awards', true) ) { ? ?php echo get_post_meta($post-ID, 'film-awards', true); ? ?php } else { ? pNo awards yet. Please petition a href = http://www.oscars.org/the Oscar committee/a./p ?php } ?
  • 28. But what about posts? The layout concepts are the same when adapting posts, but post templates are not created the same way as page templates. The difference is that the syntax for ‘single-{typename}.php is reserved for Custom Post Types. Options: — dapt existing templates by adding custom code to a single.php, index.php, archive.php, and category.php — dd conditional code to current template files, so certain a custom fields display for certain categories — se one of the many post template plugins to u recognize and apply your post templates: http://wordpress.org/plugins/search.php?q=post+template
  • 30. Think about the backend your user will see. Photo from the LOC: LC-B2- 2457-5
  • 34. C B plugins for easy fields Assign a format for the type of field you want to show
  • 35. C B plugins for easy fields You can add titles and instructions and rules to the fields you’ve chosen. Plugin settings page
  • 36. C B plugins for easy fields You can add titles and instructions and rules to the fields you’ve chosen. Plugin settings page Add/edit page screen
  • 38. C plugins for easy fields Other Custom Fields plugins Custom Fields http://wordpress.org/plugins/custom-fields/ Developers Custom Fields http://wordpress.org/plugins/developers-custom-fields/ Search for more plugins: http://wordpress.org/plugins/search.php?q=custom+fields Suggestions?
  • 40. D Next steps Where do we go from here? 1. Start thinking endlessly about content presentation options. 2. ook at lots of examples. I’ve started collecting some sites L from WP Showcase for you at this page on my blog (your contributions are welcome!): http://blog.lettergrade.ca/custom-site-library/ 3. ave fun with it! Practice for a year. (Six months if you’re H really into it.) 4. ombine all the elements you’ve practiced into planning C and building a Custom Post Type.
  • 41. THANK YOU. Questions? I’m Denise Williams and I can be found at @lettergrade.