Successfully reported this slideshow.

WordPress Advanced Custom Fields - 101

1

Share

Upcoming SlideShare
Custom post-framworks
Custom post-framworks
Loading in …3
×
1 of 34
1 of 34

WordPress Advanced Custom Fields - 101

1

Share

Download to read offline

This slide has been shown at WordPress Sydney Meetup in 11/Jun/2015.
The demo is on github https://github.com/leocaseiro/ACF-Movie-Demo

This slide has been shown at WordPress Sydney Meetup in 11/Jun/2015.
The demo is on github https://github.com/leocaseiro/ACF-Movie-Demo

More Related Content

Related Books

Free with a 30 day trial from Scribd

See all

WordPress Advanced Custom Fields - 101

  1. 1. bit.ly/wpsydacf @leocaseiro ACF ADVANCED CUSTOM FIELDS FOR WP - 101 http://bit.ly/wpsydacf By /Leo Caseiro @leocaseiro
  2. 2. WHO AM I Brazilian - Web Developer at - -IDM Renet IPMG Translator: /WordPress PT-BR Tuts+ Community: /BR WP Forum WordPress Stackoverflow WordPress Plugin Developer
  3. 3. WHY WP IS AWESOME?
  4. 4. NATIVE WP CUSTOM FIELDS
  5. 5. NATIVE WP CUSTOM FIELDS = MESS
  6. 6. ADVANCED CUSTOM FIELDS
  7. 7. ACF: TYPES OF FIELDS 4.4.2 (FREE)
  8. 8. ACF: FEATURES - VALIDATION
  9. 9. ACF: FEATURES - CONDITIONAL LOGIC
  10. 10. ACF: FEATURES - PREFIX - SUFIX - PLACEHOLDER
  11. 11. ACF: RELATIONAL
  12. 12. ACF: JQUERY - GMAPS, DATE PICKER, COLOR PICKER
  13. 13. ACF: NEED MORE? (EXTENSIONS)
  14. 14. ACF: STEP BY STEP - MOVIE DATABASE SITE
  15. 15. ACF: STEP BY STEP - MOVIE DB - TAB DETAILS
  16. 16. ACF: STEP BY STEP - CLASSIFICATION
  17. 17. ACF: STEP BY STEP - PREFIX, SUFIX AND PLACEHOLDER
  18. 18. ACF: STEP BY STEP - RELATIONAL
  19. 19. ACF: STEP BY STEP - CONDITIONAL LOGIC
  20. 20. ACF: STEP BY STEP - COUNTRY ACTOR + MOVIE
  21. 21. FRONTEND - DEMO https://github.com/leocaseiro/acf-movie-demo
  22. 22. SHOW ME SOME CODE <p><?php the_field('country'); ?></p> <?php $subtitle = get_field('country'); echo $subtitle; ?> <?php //get_post_meta() works, better to use the_field() and get_field() echo get_post_meta( get_the_ID(), 'country', true ); ?> ACF documentation
  23. 23. FRONTEND - FROM DATEPICKER TO DATE I18N <?php $release_date = get_field( 'release_date' ); //Format: yyyymmdd echo date_i18n( 'l, F j, Y', strtotime( $release_date ) ); ?> https://codex.wordpress.org/Function_Reference/date_i18n
  24. 24. FRONTEND - CONDITIONAL LOGIC <?php if ( get_field( 'has_video' ) ) : ?> <h3>Trailer</h3> <?php the_field('trailer'); //oEmbed ?> <hr> <?php endif; ?> http://www.advancedcustomfields.com/resources/code-examples/#using-conditional statements
  25. 25. FRONTEND - RELATIONAL PARENT (MOVIE) <ul> <?php $cast = get_field('cast'); foreach( $cast as $post): // var must be called $post (IMPORTANT) setup_postdata( $post ); ?> <li> <a href="<?php the_permalink(); ?>"> <?php the_title(); ?> <?php the_post_thumbnail(); ?> </a> </li> <?php wp_reset_postdata(); // IMPORTANT - reset the $post object // so the rest of the page works correctly endforeach; ?> </ul> http://www.advancedcustomfields.com/resources/code-examples/#using-conditional statements
  26. 26. FRONTEND - RELATIONAL CHILD (ACTOR) get_posts() <?php $movies = get_posts( array( 'post_type' => 'movie', 'meta_query' => array( array( 'key' => 'cast', // Field Name (ACF) 'value' => '"' . get_the_ID() . '"', //Leave "" 'compare' => 'LIKE' ) ) )); ?> http://www.advancedcustomfields.com/resources/tutorials/querying-relationship-fields/
  27. 27. FRONTEND - RELATIONAL CHILD (ACTOR) Show parents related <ul> <?php $movies = get_posts(...); //See Previous Slide foreach( $movies as $post): // var must be called $post (IMPORTANT) setup_postdata( $post ); ?> <li> <a href="<?php the_permalink(); ?>"> <?php the_title(); ?> <?php the_post_thumbnail(); ?> </a> </li> <?php wp_reset_postdata(); // IMPORTANT - reset the $post object // so the rest of the page works correctly endforeach; ?> </ul> http://www.advancedcustomfields.com/resources/tutorials/querying-relationship-fields/
  28. 28. WHY ACF? Doesn't create MySQL table User Interface 900,000+ WP Way Documentation Support similar Plugins at http://comparewp.org/
  29. 29. GO ACF PRO V5
  30. 30. ACF PRO - EXTRAS Local JSON Fields in Comments, Widget, Users Validation PHP + AJAX acf_form()
  31. 31. BEYOND THIS TALK WordPress Plugins: Advanced Custom Fields Jared Novack: Advanced Advanced Custom Fields Using Advanced Custom Fields within a WordPress Custom Theme Elliot Condon talks - WP Melbourne: Story of Advanced Custom Field - May 2013 ACF 5 Walk-through - May 2014
  32. 32. ADVANCED USE Actions and Filters Creating a new field type Extensions ACF to WP-API Plugin Local JSON Syncronized JSON http://www.advancedcustomfields.com/resources/
  33. 33. QUESTIONS?
  34. 34. CHEERS MATE! By /Leo Caseiro @leocaseiro

×