I want to create some custom fields that will be able to show to a default wordpress post. I don’t want to use the ACF plugin.
Is there anyway to do it programmatically?
Thanks
2 Answers
You can use the custom fields included in wordpress
Add a new post and do the following steps:
1. Go to the Options page
2. Select “custom fields” and hit the reload button
3. you now have a custom field in your post edit page at the bottom.
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.