Home › Forums › General Issues › Displaying Value of a Field › Reply To: Displaying Value of a Field
Wow, I feel so dumb. Just figure out my problem. LOCATION!!!!!!
foreach ( $portfolio_items as $item ) {
$image = nk_get_attachment( $item['thumbnail'], 'nk_1920x1080' );
$image_small = nk_get_attachment( $item['thumbnail'], 'nk_300x300' );
$pTitle = get_field_object('portfolio_title', $item['id']);
$pSubtitle = get_field_object('portfolio_subtitle', $item['id']);
$pTagline = get_field_object('portfolio_tagline', $item['id']);
$pLink = get_field_object('portfolio_link', $item['id']);
if ( $image || $image_small ) {
$active_class = $active_slide == $item['id'] ? 'active' : '';
$position_x = nk_get_option( 'background_x_position', 50, true, $item['id'] );
$position_y = nk_get_option( 'background_y_position', 50, true, $item['id'] );
$position = (int) $position_x . '% ' . (int) $position_y . '%';
// prepare video
$video_type = nk_get_option( 'video_type', 'disable', true, $item['id'] );
$video_url = '';
$video_size = nk_get_option( 'video_size', '', true, $item['id'] );
if ( $video_type === 'local' ) {
$mp4 = nk_get_option( 'video_mp4', '', true, $item['id'] );
$webm = nk_get_option( 'video_webm', '', true, $item['id'] );
$ogv = nk_get_option( 'video_ogv', '', true, $item['id'] );
if ( $mp4 && is_array( $mp4 ) ) {
$video_url .= 'mp4:' . esc_url( $mp4['url'] );
}
if ( $webm && is_array( $webm ) ) {
$video_url .= ( strlen( $video_url ) ? ',' : '' ) . 'webm:' . esc_url( $webm['url'] );
}
if ( $ogv && is_array( $ogv ) ) {
$video_url .= ( strlen( $video_url ) ? ',' : '' ) . 'ogv:' . esc_url( $ogv['url'] );
}
} else if ( $video_type === 'yt_vm' ) {
$video_url = nk_get_option( 'video_url', '', true, $item['id'] );
}
$categories = '';
if ( $item['categories'] && count( $item['categories'] ) > 0 ) {
foreach ( $item['categories'] as $k => $cat ) {
$categories .= ( $k > 0 ? '|' : '' ) . $cat->name;
}
}
$srcset = wp_get_attachment_image_srcset( $item['thumbnail'], 'nk_1920x1080' );
?>
<div class="nk-slider-item <?php echo esc_attr( $active_class ); ?>" data-categories="<?php echo esc_attr( $categories ); ?>" data-background-position="<?php echo esc_attr( $position ); ?>">
<?php
echo '<img
src="' . esc_url( $image['src'] ) . '"
srcset="' . esc_attr( $image_small ? $image_small['src'] : $image['src'] ) . '"
data-srcset="' . esc_attr( $srcset ) . '"
data-sizes="auto"
alt="' . esc_attr( $item['title'] ) . '"
class="lazyload"
style="object-position: ' . esc_attr( $position ) . ';"
title="'?><?php echo $pTitle['value'] ?><?php echo'"
subtitle="'?><?php echo $pSubtitle['value'] ?><?php echo'"
tagline="'?><?php echo $pTagline['value'] ?><?php echo'"
link="'?><?php echo $pLink['value'] ?><?php echo'"
>';
if ( $video_url ) {
echo '<div data-bg-video="' . esc_attr( $video_url ) . '" data-bg-video-size="' . esc_attr( $video_size ? $video_size : '16x9' ) . '"></div>';
}
?>
</div>
<?php
I was placing the acf code in the wrong area. Although, if you have a better way to code, that will be a big help too. I know, my code is sloppy. 🙁
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.