Hi,
get_field() returns NULL, if the table has no content. So you can use…
if ( get_field( 'table_classic_editor' ) !== NULL ) {
echo 'here is the table';
}
or more general if the result is one of the following NULL, FALSE or empty string ''…
if ( ! empty( get_field( 'table_classic_editor' ) ) ) {
echo 'here is the table';
}
WPML should not be part of that problem.
Cheers,
Johann
-
This reply was modified 7 years, 4 months ago by
Johann Heyne.
-
This reply was modified 7 years, 4 months ago by
Johann Heyne.
-
This reply was modified 7 years, 4 months ago by
Johann Heyne.
-
This reply was modified 7 years, 4 months ago by
Johann Heyne.
Hi,
I was wrong. For some reason I´ve got NULL using get_field(). But it should be FALSE on an empty table so that your code example should work.
I´m going to investigate that.
Cheers,
Johann
OK, get_field() returns NULL, if the requested field is not saved in the database. If there is an empty table saved in the database, get_field() returns FALSE. So using
if ( ! empty( get_field( 'my-table' ) ) {
}
ist the way, that should work.
Cheers,
Johann
-
This reply was modified 7 years, 4 months ago by
Johann Heyne.
Hi Johann,
Thanks for your reply. It still didn’t work, but it was my mistake.
I use the table in a custom post type, and copied the first post and edited the information, so that the headers of the table will always be the same.
I just emptied the table’s content without removing the columns and rows.
Obviously, that doesn’t count as it being empty or null.
So, a table is only empty if it doesn’t have any cells or rows.