Dear Sir/Madam,
I don't find the reason why my shortcode affect the custom field data display in View, I do execute the wp_reset_postdata(), it should resume the post record.
All custom field will return empty value if I paste the shortcode before them.
[membership_pay numbeds="[types field='actual-bednum' format='FIELD_VALUE'][/types]" membership_id="[types field='member-id'][/types]" expiry="[types field='expiry-date' output='raw'][/types]"]
shortcode script in functions.php
function ebz_membership_pay($atts) {
$args = array(
'post_type' => 'membership-group',
'post_status' => 'publish',
'posts_per_page' => -1,
);
$the_query = new WP_Query($args);
$num = intval($atts['numbeds']);
if ( $the_query->have_posts() ) {
$range = [];
while ( $the_query->have_posts() ) {
$the_query->the_post();
$membership_cat = get_post_meta(get_the_ID(), 'wpcf-membership-category', true);
$membership_fee = get_post_meta(get_the_ID(), 'wpcf-membership-fee', true);
$product_id = get_post_meta(get_the_ID(), 'wpcf-membership-product-id', true);
$values = explode("_", $membership_cat);
array_push($range, ["min"=>$values[1], "max"=>$values[2], "fee"=>$membership_fee, "sku"=>$membership_cat]);
}
}
wp_reset_postdata();
if (intval($atts['expiry']) < (time() + 180 * 24 * 60 * 60)) {
foreach ($range as $key=>$value) {
if (in_array($num, range($value['min'], $value['max']), true)) {
$rtn = sprintf("<a target='_blank' href='<em><u>hidden link</u></em> class='btn btn-success btn-xs'>繳交會費</button></a>", $atts['membership_id'], $product_id);
}
}
}
return $rtn;
}
add_shortcode('membership_pay', 'ebz_membership_pay');
The $rtn can be correctly returned html
Hello,
It is a custom codes problem, there might be some PHP errors in your website, please try to get the PHP debug logs:
https://toolset.com/documentation/programmer-reference/debugging-sites-built-with-toolset/#php-debugging
If you need more assistance for it, please provide a test site with the same problem, also point out the problem page URLs, and where I can edit your custom PHP codes.