Hi, i have a custom fields group for custom posts type.
I have two fields - date and address.
Date is displayed as date type and show the correct content for each post.
Address is displayed as raw type, but for all the posts it shows the last entered value (not the actual one).
Display code looks like this:
<?php $args = array( 'post_type' => 'event', 'posts_per_page' => 2 );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
$event_date = types_render_field("date", array("output"=>"date"));
$event_address = types_render_field("address", array("output"=>"raw"));
echo '<div class="eventus">';
echo '<h3><a href="'; the_permalink(); echo '">',the_title(),'</a></h3>';
echo '<p><a href="'; the_permalink(); echo '">';
printf($event_date);
echo ' - ';
printf($event_address);
echo '</a></p></div>';
endwhile; wp_reset_query(); ?>
Why isn't it showing the correct data?
Hi semionB,
Please try replace this line in the codes you mentioned above from:
endwhile; wp_reset_query(); ?>
To:
endwhile; wp_reset_postdata(); ?>
More help:
Note: If you use the_post() with your query, you need to run wp_reset_postdata() afterwards to have Template Tags use the main query's current post again.
http://codex.wordpress.org/Class_Reference/wp_reset_query
Hi luoy,
it didn't help. Still have the same issue.
I can not duplicate same problem in my localhost, Please try this:
1) deactivate other plugins and switch to wordpress default theme,
2) enable wordpress debug mode, repeat the actions you mentioned above, and post the debug logs here.
https://toolset.com/documentation/user-guides/debugging-types-and-views/
Hi again,
no errors in debug mode.
I tried to use standard wp custom field output, using the address custom field real name (wpcf-address).
echo get_post_meta($post->ID, 'wpcf-address', true);
and it works.
Could you duplicate same problem in a test site, and fill below private details box with the login details,
Also point out the problem page URL, and where I can check your custom PHP codes. I need a live website to debug this problem. thanks
Hi,
the code is in header.php
Where can I see the problem in front-end, I checked the homepage of your website, it display different date, like this:
Upcoming Events
Eve
August 12, 2014 - Street 2
Event 4
August 23, 2014 - Street 2
The problem is not in dates, the problem is in addresses.
I have tried export the settings from your website, and import to my localhost, it works fine,
Please try deactivate other plugins and switch to wordpress default theme twentyfourteen, you are using a custom theme