Plugin Contributor
pwtyler
(@pwtyler)
Hi Dan—
Sorry for the belated response, I just saw this, I’ll take a look and get back asap!
best,
Phil
Plugin Contributor
pwtyler
(@pwtyler)
Hi Dan—
It seems like get_field (or whatever you are using in the template) is returning a literal string of ‘null’, which I’ve actually not been able to replicate. When I do not choose a table in the dropdown, and use the following code in my template,
$tablepress_id = get_field( 'tp' );
$args =[ 'id' => $tablepress_id ];
if ( function_exists( 'tablepress_print_table' ) ) {
tablepress_print_table( $args );
}
I see on the front-end [table “” not found /]
, which I would say is to be expected. My guess is, you will want to amend the if statement you wrapped the display part of the code to also check that $tablepress_id does not equal ‘null’, something like
$tablepress_id = get_field( 'tp' );
if ( ! empty( $tablepress_id ) && $tablepress_id != 'null' ) {
$args =[ 'id' => $tablepress_id ];
if ( function_exists( 'tablepress_print_table' ) ) {
tablepress_print_table( $args );
}
}
I’m sorry I don’t have a better explanation as to WHY it’s happening, but could you tell me exactly what code you are using in your template, and what version of ACF you are using? I tried both ACF 4 and 5, but neither returned a literal ‘null’ string like you’re getting.
Thanks for your attention and help. I did actually manage to solve the problem eventually by using the following code:
<?php
$section = get_field('custom_field');
if ($section != "null") :
?>
<?php
$table = get_field('my_table');
if ($table != "null") {
echo do_shortcode( '[table id="'. get_field('my_table') .'" /]' );
} ?>
<?php endif; ?>
-
This reply was modified 6 years, 11 months ago by dancappdesign.
-
This reply was modified 6 years, 11 months ago by dancappdesign. Reason: Code quote formatting