Community Forums › Forums › Archived Forums › Design Tips and Tricks › Genesis and Advanced Custom fields
- This topic has 2 replies, 2 voices, and was last updated 11 years, 3 months ago by Au Coeur.
-
AuthorPosts
-
December 2, 2012 at 9:18 am #2845Au CoeurMember
I am using ACF to display a bunch of custom fields on a new website (I can't link to it because it has a maintenance mode plugin and isn't visible unless you are logged in -- I know that is less than ideal, sorry -- but it looks like you can view source without being logged in so here is a link to the source of the page in question), and am having trouble getting a few of the fields to function properly when they are output on the site.
I followed Nick's tutorial and am using the following code to display the ACFs:
/** Add Custom Fields If Available**/
/**
* Gets the custom field value if available and places it in a defined pattern.
* Place %value% where the custom field value should be if custom field is returned.
*
* @uses genesis_get_custom_field()
* @param string $field the id of the custom field to check/retrieve.
* @param string $wrap HTML to return if custom field is returned.
* @param boolean $echo default false. echo wraped field value if available and set to true.
* @returns string/boolean the custom field/wrap output or false if nothing
*
*/
function ntg_get_custom_field( $field, $wrap = '%value%', $echo = false ){$custom_wrap = false;
if( $value = genesis_get_custom_field( $field ) )
$custom_wrap = str_replace( '%value%', $value, $wrap );if( $echo && $custom_wrap )
echo $custom_wrap;return $custom_wrap;
}
add_action( 'genesis_before_post_content', 'ntg_event_info', 5 );
function ntg_event_info() {if( ! is_single() )
return;ntg_get_custom_field( 'price', '<div class="event-inline">'. '<h4>Price</h4><div class="event-price">%value%</div></div>', true );
ntg_get_custom_field( 'bucket_rating', '<div class="event-inline">'. '<h4>Bucket Rating</h4><div class="event-price">%value%</div> </div>', true );
ntg_get_custom_field('age_range', '<div class="event-inline">'. '<h4>Ages</h4>%value%</div>', true );}
add_action( 'genesis_before_post_content', 'ntg_venue_location', 5 );
function ntg_venue_location() {if( ! is_single() )
return;ntg_get_custom_field( 'venue_name', '<div class="venue-location">'. '<h4>Location Information</h4>%value%</div>', true );
ntg_get_custom_field( 'street', '<div class="venue-street">'. '%value%</div>', true );
ntg_get_custom_field( 'city', '<div class="venue-inline">'. '%value%,</div>', true );
ntg_get_custom_field( 'state', '<div class="venue-inline">'. '%value%</div>', true );
ntg_get_custom_field( 'zip', '<div class="venue-inline">'. '%value%</div>', true );
ntg_get_custom_field( 'phone', '<div class="venue-phone">'. '<br/>%value%</div>', true );
ntg_get_custom_field( 'website', '<div class="venue-website">'. '%value%</div>', true );
ntg_get_custom_field( 'map', '<div class="venue-map">'. '%value%</div>', true );
}Here is my problem:
This displays the data beautifully, except in two cases.
The checkbox field returns the word "array," rather than comma separated values when multiple options are selected.
The WYSIWYG editor loses its ability to process shortcodes and is just displaying the shortcode as text.I know this has something to do with the code I am using and that the genesis code is not be correctly calling the fields so that they can maintain all of their functionality. I need to use get_field as a function to maintain the ACF fields' functionality, but I cannot figure out how to make that work with Genesis. I asked the developer about it, but he wasn't sure about making it work with Genesis, so I'm hoping someone here will.
Thanks!
Mother. Web & Graphic Designer. Lactation Consultant. Blogging about how it all fits together, most recently from northern Colorado. Visit my blog or my design site.
December 2, 2012 at 9:56 am #2852nickthegeekMemberI think I pointed it out in the tutorial. In some cases the genesis_custom_field() functions will not work. Stored arrays are an instance where you will need a bit more complicated solution. I haven't worked with ACF very much but I think they have their own function that pulls and formats the fields so the arrayed values are properly presented.
December 3, 2012 at 8:19 am #2985Au CoeurMemberThey do have a function I was just having a hard time figuring out how to implement. I'm still largely trial and error or copy-paste when it comes to PHP. I eventually figured out where to put it, though.
Mother. Web & Graphic Designer. Lactation Consultant. Blogging about how it all fits together, most recently from northern Colorado. Visit my blog or my design site.
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.