Skip Navigation

[Closed] Custom field display the same value (last entered)

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This support ticket is created 9 years, 8 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

Tagged: 

This topic contains 9 replies, has 2 voices.

Last updated by Luo Yang 9 years, 8 months ago.

Assisted by: Luo Yang.

Author
Posts
#234524

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?

#234564

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

#234623

Hi luoy,
it didn't help. Still have the same issue.

#234811

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/

#234860

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.

#234994

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

#235448

Hi,
the code is in header.php

#235681

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

#235690

The problem is not in dates, the problem is in addresses.

#235882

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

The topic ‘[Closed] Custom field display the same value (last entered)’ is closed to new replies.