W
W
web_Cat2021-07-19 01:32:50
WordPress
web_Cat, 2021-07-19 01:32:50

How to check for empty lines and not write to the database?

There are metaboxes for writing to WordPress, how to check for empty lines and not write to the database if there is no data? I suppose through empty, but there is not enough knowledge.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artem Zolin, 2021-07-21
@artzolin

// Обновляем данные в базе
if ( !empty( $my_data ) ) {
  update_post_meta( $post_id, 'my_meta_key', $my_data );
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question