Advanced Custom Fields
Flexible layouts and other cool stuff!
by Kirsty Burgoine
www.kirstyburgoine.co.uk
twitter.com/kirstyburgoine
info@kirstyburgoine.co.uk
Who am I?
• Web developer / designer
• Run my own business in
Shrewsbury / Shropshire
• Organiser of Shropgeek which
includes:
- Socials
- Rebellion (mini conferences)
- (R)Evolution (annual
conference)
• and I ‘~ grin!’ alot
A little about Advanced Custom Fields ...
General Settings
• Adding the group and field
Label, Name, Type,
Conditional Logic
• Location
Show on specific pages,
posts, taxonomy etc.
• Options
Position, Style, hide on
screen
Creating Custom Fields
The Flexible Content field
What you will need:
• Flexible Content Field
• Repeater Field
Both are premium fields and cost $25.00 AUD each.
http://www.advancedcustomfields.com/add-ons/
Creating the Flexible Content field
And here’s one I made earlier....
Editing the Fields
• Layouts - This will display in popup when editing the page
• Create sub field within the layout that could be used for Flexible
content.
• For multiple columns set as a Repeater Field
• Add repeater fields inside the sub field
• Set a maximum number of rows. This will make your CSS easier to
manage.
• For more layouts, click Add New under each layout and repeat
process
Adding flexible content to the page
And here’s one I made earlier....
Building the flexible content into our theme
Step 1
Create the main page template: flexible-content.php
In that template create a new loop for the flexible content within the
main loop using has_field()
The page template
Step 2
Create the template part for each layout.
content-flexible-text.php
content-flexible-carousel.php
Careful to use the name of the layout i.e. text, carousel
We can now automatically pull in the right type of content based on the
selection made in the admin panel
The template part
Example used here is content-flexible-text.php
First of all we need to get all of the content from the Text Flexible
Content Field
$columns is a repeater field so we initiate a new loop and get all of the
content from each sub field
oEmbed Tip: Make sure video links are not hyperlinked!
The template part
Then display the content:
The template part - CSS
The template part - CSS
Step 3
Setup the columns to create their class dynamically
$columns is our repeater field. $text_count counts the number of fields
created.
We originally limited our columns to 4 when creating the flexible
content field so we know the classes created here will be .span1,
.span2, .span3, .span4
The template part - CSS
The template part - CSS
Making the columns responsive:
As well as the CSS I also used fitvids.js to make the videos responsive
Google Maps & the Locations field
What you will need:
•Location Field
•Knowledge of Google Maps API v3
The location field is a free add on.
http://www.advancedcustomfields.com/add-ons/
Creating the Location field
And here’s one I made earlier....
Creating the locations
Create a new
page for each
separate
location.
The location field
group is set to
only show on
child pages of
the main
locations page.
Displaying each location on the page
Step 1
Add the google map container <div> to content-page.php
In this case the post parent is our main locations page.
The container has been added outside of .content-entry to avoid any
distortion caused by the CSS .content-entry img { max-width: 100%; }
Displaying each location on the page
Step 2
Within the loop get the locations field using get_field();
Add the javascript for Google maps
Displaying each location on the page
The location field is an array that allows you to use the original address
inputted and the coordinates returned.
In the example given, we used $post_code[‘coordinates’] in the
Google maps javascript.
Notice there is also a custom image for the map marker here.
Displaying all locations on one map
Step 1
Create the main page template: locations-main.php
Step 2
Add the google map container <div> to the page
Step 3
Create the map and add the markers ...
Displaying all locations on one map
Step 3 continued.
Create a new loop
that finds all of the
location
coordinates.
This loop then
needs to insert all
of the information
into an array called
$marker for later
use in a our
javascript.
Displaying all locations on one map
Step 3 continued.
The Javascript.
This example shows how
each marker is created
and where it is placed.
Full code can be found in
locations-main.php
Dealing with Images
What you will need:
•Gallery Field
The gallery field is a premium add on and costs $25.00 AUD.
http://www.advancedcustomfields.com/add-ons/
Dealing with Images
And here’s one I made earlier....
Images and the Gallery field type
Image Return
Values
The Image
Object array
returns a lot of
information we
can use:
Gallery field type
Gallery field automatically stores all information about each image in an
Image Object.
This allows us to do some cool stuff with them.
Creating a gallery of images
Create the flexible content field for the gallery.
Here’s one I made earlier ...
Creating a gallery of images
Create the template part for the layout. This will be a flexible layout as
well.
content-flexible-carousel.php
Once created, get all of the content from the flexible content carousel
fields
$carousel_images is an array so we need to create a foreach loop to
access all of the information
Creating a gallery of images
To create the carousel I used flexslider 2 from Woothemes:
http://flexslider.woothemes.com/index.html
Thank you.
Credits and Resources
• www.advancedcustomfields.com
• fitvidsjs.com/
• flexslider.woothemes.com/index.ht
ml
• placekitten.com
• www.kirstyburgoine.co.uk
• twitter.com/kirstyburgoine
• info@kirstyburgoine.co.uk
All theme files can be found on github at:
• https://github.com/kirstyburgoine/wcuk20
13

More Related Content

PDF
WP London Meetup - August 2013
PPTX
Chapter 4 class power point
PDF
Extending word press
PDF
WordPress Custom Fields: Control your content presentation by breaking out of...
PDF
Advanced Custom Fields: Amazing Possibilities and Irritating Limitations
PDF
Contentful with Netgen Layouts workshop
PDF
Creating a web gallery lightbox2 final
PDF
Building rednoseday.com on Drupal 8
WP London Meetup - August 2013
Chapter 4 class power point
Extending word press
WordPress Custom Fields: Control your content presentation by breaking out of...
Advanced Custom Fields: Amazing Possibilities and Irritating Limitations
Contentful with Netgen Layouts workshop
Creating a web gallery lightbox2 final
Building rednoseday.com on Drupal 8

Similar to WCUK2013 - ACF Flexible Content and other cool stuff (20)

PPTX
GDG On Campus SECE - Web Development Session.pptx
PDF
Make Meta Boxes Great Again
PPTX
Creative i media r085
PPTX
Page object from the ground up by Joe Beale
PPTX
Page object from the ground up.ppt
PPT
Web development basics (Part-2)
PDF
AD0-E116-demo.pdf
PPSX
14 asp.net session20
PPTX
Bootstrap SLIDES for web development course
PPTX
HTML and CSS.pptx
PDF
The New CSS Layout - Dutch PHP Conference
PPTX
Building Potent WordPress Websites
PPTX
Make Meta Boxes Great Again
PPTX
PROJECT PPT.pptx_20241015_092516_0000.pptx
PDF
Wordpress beyond blogging
DOC
Cis363 all i labs devry university
DOC
Cis363 a all ilabs devry university
DOC
Cis363 a all ilabs devry university
DOC
Cis363 all i labs devry university
PPTX
ICT Presentjrjdjdjdkkdkeeation Final.pptx
GDG On Campus SECE - Web Development Session.pptx
Make Meta Boxes Great Again
Creative i media r085
Page object from the ground up by Joe Beale
Page object from the ground up.ppt
Web development basics (Part-2)
AD0-E116-demo.pdf
14 asp.net session20
Bootstrap SLIDES for web development course
HTML and CSS.pptx
The New CSS Layout - Dutch PHP Conference
Building Potent WordPress Websites
Make Meta Boxes Great Again
PROJECT PPT.pptx_20241015_092516_0000.pptx
Wordpress beyond blogging
Cis363 all i labs devry university
Cis363 a all ilabs devry university
Cis363 a all ilabs devry university
Cis363 all i labs devry university
ICT Presentjrjdjdjdkkdkeeation Final.pptx
Ad

More from Kirsty Burgoine (7)

PDF
Wpldn july2015 usb
PDF
WC Birmingham 2015
PPTX
Smile - Its never that bad! Mastering the sales meeting without turning to th...
PPTX
The dark art of sales meetings - WordCamp Bournemouth Version
PPTX
Question of deliverables and other such stuff
PDF
Speak the Web - Liverpool 24.07.13
PDF
Working with designers that dont code
Wpldn july2015 usb
WC Birmingham 2015
Smile - Its never that bad! Mastering the sales meeting without turning to th...
The dark art of sales meetings - WordCamp Bournemouth Version
Question of deliverables and other such stuff
Speak the Web - Liverpool 24.07.13
Working with designers that dont code
Ad

Recently uploaded (20)

PPTX
TEXTILE technology diploma scope and career opportunities
PPTX
The various Industrial Revolutions .pptx
PDF
Flame analysis and combustion estimation using large language and vision assi...
PDF
The influence of sentiment analysis in enhancing early warning system model f...
PDF
STKI Israel Market Study 2025 version august
PDF
Five Habits of High-Impact Board Members
PDF
Produktkatalog für HOBO Datenlogger, Wetterstationen, Sensoren, Software und ...
PPTX
Benefits of Physical activity for teenagers.pptx
PDF
Developing a website for English-speaking practice to English as a foreign la...
PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
PDF
How IoT Sensor Integration in 2025 is Transforming Industries Worldwide
PPT
What is a Computer? Input Devices /output devices
PDF
Taming the Chaos: How to Turn Unstructured Data into Decisions
PPTX
Final SEM Unit 1 for mit wpu at pune .pptx
PDF
Architecture types and enterprise applications.pdf
PDF
1 - Historical Antecedents, Social Consideration.pdf
PDF
A contest of sentiment analysis: k-nearest neighbor versus neural network
PPTX
Custom Battery Pack Design Considerations for Performance and Safety
PPTX
Chapter 5: Probability Theory and Statistics
PPTX
Modernising the Digital Integration Hub
TEXTILE technology diploma scope and career opportunities
The various Industrial Revolutions .pptx
Flame analysis and combustion estimation using large language and vision assi...
The influence of sentiment analysis in enhancing early warning system model f...
STKI Israel Market Study 2025 version august
Five Habits of High-Impact Board Members
Produktkatalog für HOBO Datenlogger, Wetterstationen, Sensoren, Software und ...
Benefits of Physical activity for teenagers.pptx
Developing a website for English-speaking practice to English as a foreign la...
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
How IoT Sensor Integration in 2025 is Transforming Industries Worldwide
What is a Computer? Input Devices /output devices
Taming the Chaos: How to Turn Unstructured Data into Decisions
Final SEM Unit 1 for mit wpu at pune .pptx
Architecture types and enterprise applications.pdf
1 - Historical Antecedents, Social Consideration.pdf
A contest of sentiment analysis: k-nearest neighbor versus neural network
Custom Battery Pack Design Considerations for Performance and Safety
Chapter 5: Probability Theory and Statistics
Modernising the Digital Integration Hub

WCUK2013 - ACF Flexible Content and other cool stuff

  • 1. Advanced Custom Fields Flexible layouts and other cool stuff! by Kirsty Burgoine www.kirstyburgoine.co.uk twitter.com/kirstyburgoine info@kirstyburgoine.co.uk
  • 2. Who am I? • Web developer / designer • Run my own business in Shrewsbury / Shropshire • Organiser of Shropgeek which includes: - Socials - Rebellion (mini conferences) - (R)Evolution (annual conference) • and I ‘~ grin!’ alot
  • 3. A little about Advanced Custom Fields ...
  • 4. General Settings • Adding the group and field Label, Name, Type, Conditional Logic • Location Show on specific pages, posts, taxonomy etc. • Options Position, Style, hide on screen Creating Custom Fields
  • 5. The Flexible Content field What you will need: • Flexible Content Field • Repeater Field Both are premium fields and cost $25.00 AUD each. http://www.advancedcustomfields.com/add-ons/
  • 6. Creating the Flexible Content field And here’s one I made earlier....
  • 7. Editing the Fields • Layouts - This will display in popup when editing the page • Create sub field within the layout that could be used for Flexible content. • For multiple columns set as a Repeater Field • Add repeater fields inside the sub field • Set a maximum number of rows. This will make your CSS easier to manage. • For more layouts, click Add New under each layout and repeat process
  • 8. Adding flexible content to the page And here’s one I made earlier....
  • 9. Building the flexible content into our theme Step 1 Create the main page template: flexible-content.php In that template create a new loop for the flexible content within the main loop using has_field()
  • 10. The page template Step 2 Create the template part for each layout. content-flexible-text.php content-flexible-carousel.php Careful to use the name of the layout i.e. text, carousel We can now automatically pull in the right type of content based on the selection made in the admin panel
  • 11. The template part Example used here is content-flexible-text.php First of all we need to get all of the content from the Text Flexible Content Field $columns is a repeater field so we initiate a new loop and get all of the content from each sub field oEmbed Tip: Make sure video links are not hyperlinked!
  • 12. The template part Then display the content:
  • 13. The template part - CSS The template part - CSS Step 3 Setup the columns to create their class dynamically $columns is our repeater field. $text_count counts the number of fields created. We originally limited our columns to 4 when creating the flexible content field so we know the classes created here will be .span1, .span2, .span3, .span4
  • 14. The template part - CSS The template part - CSS Making the columns responsive: As well as the CSS I also used fitvids.js to make the videos responsive
  • 15. Google Maps & the Locations field What you will need: •Location Field •Knowledge of Google Maps API v3 The location field is a free add on. http://www.advancedcustomfields.com/add-ons/
  • 16. Creating the Location field And here’s one I made earlier....
  • 17. Creating the locations Create a new page for each separate location. The location field group is set to only show on child pages of the main locations page.
  • 18. Displaying each location on the page Step 1 Add the google map container <div> to content-page.php In this case the post parent is our main locations page. The container has been added outside of .content-entry to avoid any distortion caused by the CSS .content-entry img { max-width: 100%; }
  • 19. Displaying each location on the page Step 2 Within the loop get the locations field using get_field(); Add the javascript for Google maps
  • 20. Displaying each location on the page The location field is an array that allows you to use the original address inputted and the coordinates returned. In the example given, we used $post_code[‘coordinates’] in the Google maps javascript. Notice there is also a custom image for the map marker here.
  • 21. Displaying all locations on one map Step 1 Create the main page template: locations-main.php Step 2 Add the google map container <div> to the page Step 3 Create the map and add the markers ...
  • 22. Displaying all locations on one map Step 3 continued. Create a new loop that finds all of the location coordinates. This loop then needs to insert all of the information into an array called $marker for later use in a our javascript.
  • 23. Displaying all locations on one map Step 3 continued. The Javascript. This example shows how each marker is created and where it is placed. Full code can be found in locations-main.php
  • 24. Dealing with Images What you will need: •Gallery Field The gallery field is a premium add on and costs $25.00 AUD. http://www.advancedcustomfields.com/add-ons/
  • 25. Dealing with Images And here’s one I made earlier....
  • 26. Images and the Gallery field type Image Return Values The Image Object array returns a lot of information we can use:
  • 27. Gallery field type Gallery field automatically stores all information about each image in an Image Object. This allows us to do some cool stuff with them.
  • 28. Creating a gallery of images Create the flexible content field for the gallery. Here’s one I made earlier ...
  • 29. Creating a gallery of images Create the template part for the layout. This will be a flexible layout as well. content-flexible-carousel.php Once created, get all of the content from the flexible content carousel fields $carousel_images is an array so we need to create a foreach loop to access all of the information
  • 30. Creating a gallery of images To create the carousel I used flexslider 2 from Woothemes: http://flexslider.woothemes.com/index.html
  • 32. Credits and Resources • www.advancedcustomfields.com • fitvidsjs.com/ • flexslider.woothemes.com/index.ht ml • placekitten.com • www.kirstyburgoine.co.uk • twitter.com/kirstyburgoine • info@kirstyburgoine.co.uk All theme files can be found on github at: • https://github.com/kirstyburgoine/wcuk20 13

Editor's Notes

  • #2: Started off as Magic Fields Presume a certain amount of knowledge about building themes and creating templates