Support Forum
Support › MB Custom Post Type › ✅Display CPT in page › Reply To: Display CPT in page
Hi Huy,
Your code has a PHP error and can't work. The function pt
doesn't understand the variable $pricing
.
I have rewritten your code as follows, please try it:
// Sub function
function pt( $pricing ) {
$table = isset( $pricing['pricing_table_id'] ) ? $pricing['pricing_table_id'] : '';
if ( ! $table ) {
return;
}
$plans = rwmb_meta( 'plan', '', $table );
if ( empty( $plans ) ) {
return;
}
foreach ($plans as $plan) {
$name = isset( $plan['plan_name'] ) ? $plan['plan_name'] : '';
echo $name;
}
}
//Main function
function page_section() {
$sections = rwmb_meta( 'section' );
if ( ! empty( $sections ) ) {
return;
}
foreach ( $sections as $section ) {
if ( empty( $section['section_pricing'] ) {
continue;
}
$pricing = $section['section_pricing'];
pt( $pricing );
}
}