Home › Forums › Front-end Issues › Retrieving cell values from options table on specific page template › Reply To: Retrieving cell values from options table on specific page template
Hi @cjg79
I think it will be better if you set the ‘trip’ subfield as a post object field. That way, the options page and the trip page has a relation which you can use it later. After that, you can check the current price like this (it’s important to put it inside the loop):
<?php while ( have_posts() ) : the_post(); ?>
<div class="dynamic-price">
<?php
$costs = get_field('dates_costs_2016', 'options');
foreach( $costs as $cost ) {
if( $cost['trip']->ID == get_the_ID() ){
echo $cost['package_price'];
}
}
?>
</div>
<?php
get_template_part( 'content', 'page' );
endwhile; // end of the loop. ?>
I hope this helps 🙂
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.