Main string of code (that doesn’t work):
<span class="price-in-kune"><?php the_field('tariff_price_kn') ?> kn</span>
JavaScript
x
<?php
$args = array(
'post_type' => 'tariffs',
'posts_per_page' => 3,
'type_of_site' => 'landing_page_type',
);
$webTariffs = new WP_Query($args);
while ($webTariffs->have_posts()) {
$webTariffs->the_post();?>
<div class="pricing-item">
<div class="pricing-item-header">
<h3><?php the_title() ?></h3>
<span class="price-in-kune"><?php the_field('tariff_price_kn') ?> kn</span>
</div>
</div>
<?php } ?>
The ways i tried to solve this problem:
- put insted of
the_field('tariff_price_kn')
–echo('hi')
– the code worked - add
$post_id -> the_field('tariff_price_kn', $post_id)
$currencyKune = get_field('tariff_price_kn');
And thenecho $currencyKune
P.S 3) i don’t know exactly where should i put $currencyKune = get_field('tariff_price_kn')
, so i put it before while at first time – doesn’t work and at the second time i put it after $webTariffs->the_post();
Advertisement
Answer
Try this :
JavaScript
<?php
$args = array(
'post_type' => 'tariffs',
'posts_per_page' => 3
);
$the_query = new WP_Query( $args );
?>
<?php if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<div class="col-sm-6">
<h2 class="the-title"><?php the_field('tariff_price_kn', $post->ID); ?> + <?php the_title() ;?> </h2>
</div>
<?php endwhile; else: ?> Nothing here <?php endif; ?>
<?php wp_reset_query(); ?>