php - the_field doesn't work after put one custom post type into another custom post type
i have such code:
<?php
$args = array(
'post_type' => 'tariffs',
'posts_per_page' => 3,
'type_of_site' => 'landing_page_type_hr',
);
$webTariffs = new WP_Query($args);
while ($webTariffs->have_posts()) :
$webTariffs->the_post();
?>
<h3><?php the_title() ?></h3>
<span class="website-price"><?php the_field('Tariff price euro'); ?>
<?php the_content() ?>
<?php
endwhile;
?>
this code display custom post type on page like this:
When i create a new custom post type not as an element but as page and display this element on my page is working. Also before this code <?php the_field('name_of_page_field') ?>
is working. But...
The problem: If i try to use <?php the_field('name_of_field') ?>
after this code i have no results.
Maybe i can somehow clear all arguments or while loop after this code
Answer
Solution:
<?php wp_reset_postdata(); ?>
it was needed in the end of the code
Source