Upload
leo-caseiro
View
70
Download
4
Tags:
Embed Size (px)
Citation preview
bit.ly/wpsydacf
@leocaseiro
ACFADVANCED CUSTOM FIELDS FOR WP - 101
http://bit.ly/wpsydacfBy / Leo Caseiro @leocaseiro
WHO AM IBrazilian - Web Developer at - - IDM Renet IPMG
Translator: / WordPress PT-BR Tuts+
Community: / BR WP Forum WordPress Stackoverflow
WordPress Plugin Developer
FRONTEND - DEMO https://github.com/leocaseiro/acf-movie-demo
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
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
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
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
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/
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/
WHY ACF?
Doesn't create MySQL table
User Interface900,000+
WP Way
DocumentationSupport
similar Plugins at http://comparewp.org/
ACF PRO - EXTRASLocal JSONFields in Comments, Widget, UsersValidation PHP + AJAXacf_form()
BEYOND THIS TALKWordPress Plugins: Advanced Custom FieldsJared Novack: Advanced Advanced Custom FieldsUsing Advanced Custom Fields within a WordPress Custom Theme
Elliot Condon talks - WP Melbourne:
Story of Advanced Custom Field - May 2013ACF 5 Walk-through - May 2014
ADVANCED USEActions and FiltersCreating a new field typeExtensionsACF to WP-API PluginLocal JSONSyncronized JSON
http://www.advancedcustomfields.com/resources/