• 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

    • This topic was modified 2 years, 5 months ago by station7. Reason: fix code
    • This topic was modified 2 years, 5 months ago by station7. Reason: Figured out how to get the current page ID
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Making custom fields required?’ is closed to new replies.