Making custom fields required?
-
Hi all,
I’m creating my first custom theme which includes a special layout section for post and page summaries.
I tried using the built-in post excerpt feature, but was frustrated to discover that it (Gutenberg) generates its own HTML that I can’t easily modify (specifically a P tag), so it’s not usable for what I want to do.
I decided to create a custom field instead, and the editors will just have to manually fill this in. I used this page as a guide: https://www.ads-software.com/support/article/custom-fields/
My custom field is called “Summary”. How can I:
1. Restrict the number of characters editors can enter, and more importantly
2. How can I set this field to required so the editors don’t leave it blank?I’ll be displaying the custom field as follows:
<?php $post_id = get_the_ID(); echo get_post_meta($post_id, 'Summary', true); ?>
But I don’t want it to be blank
- The topic ‘Making custom fields required?’ is closed to new replies.