Skip Navigation

[Resolved] Field in WordPress Archive displays in dev but not in Production

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 3 replies, has 2 voices.

Last updated by Minesh 5 months, 3 weeks ago.

Assisted by: Minesh.

Author
Posts
#2701108

Hi Support

We recently developed a Toolset WordPress Archive.

dev: hidden link
www: hidden link

On Production, the custom field wpcf-nanny-what-i-can-offer in the CPT Nanny Ads is not displaying. It's wrapped in a conditional statement to check its length, based on the code in this ticket: https://toolset.com/forums/topic/trying-to-use-strlen-in-a-conditional-to-show-text-if-a-field-is-x-characters/

Custom code snippet:

<?php

toolset_snippet_security_check() or die( 'Direct access is not allowed' );

add_shortcode( 'fieldlength', function( $atts ){

	global $post;

	$string = get_post_meta( $post->ID, $atts['field'], true);

	return strlen( $string );
});

Then using the example from this ticket: https://toolset.com/forums/topic/create-excerpt-from-custom-field-2, it checks whether the length of that field exceeds 249 characters, if so display the shortened version, if not display the full version.

It is all working fine on dev, but I cannot see why it's not working on production. I added the exact same custom code to dev and www sites, and registered shorten_string as a function in Front-end Content tab of Toolset > Settings. I cannot see anything environment specific in the code.

Please help us to understand what the issue is.

Thanks and kind regards
Simon

#2701224

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Can you please check now: hidden link

The issue was you did not added the "fieldlength" under section "Functions inside conditional evaluations" at Toolset => Settings => Front-end Content

Also, You will have to clear the cache for all the languages from WP Rocket.

#2701231
Screenshot 2024-06-05 at 15.47.37.png
Screenshot 2024-06-05 at 15.47.08.png

HI Minesh

Thanks, I have cleared the WP Rocket cache on production and see the field being displayed now.

However that's curious, as it works on dev WITHOUT having the fieldlength there (see screenshots). Can you explain why it works on dev without?! (I think you still have access on dev from our other open ticket).

Kind regards
Simon

#2701241

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

It seems to be really cache issue. I just removed the "fieldlength" from the "Functions inside conditional evaluations" at Toolset => Settings => Front-end Content and I can see it working on your production site.