Add custom fields to post programmatically

You can use the custom fields included in wordpress

Add a new post and do the following steps:

1. Go to the Options page

select options page

2. Select “custom fields” and hit the reload button

select the custom field option and reload

3. you now have a custom field in your post edit page at the bottom.

custom field

now you can use this custom field in your theme inside the post-loop

<?php while ( have_posts() ) : the post(); ?>

    <?php echo get_post_meta($post->ID, 'featured', true); ?>

<?php endwhile; ?>

You have to replace ‘featured’ with the name of your custom field.

Once you created a custom field, you can use it in your others post as well.

Hope this is helpful.