Please help me out.I am battling since three days.
How to fetch value of a custom field to display it in post content area?
Please help me out.I am battling since three days.
How to fetch value of a custom field to display it in post content area?
You can get custom field to display using below code:
get_post_meta($post_id, $key, $single);
Custom field data can be fetched inside template (inside loop) using this functions:
Fetches all fields
<?php the_meta(); ?>
OR for specific value
get_post_meta($post_id, $key, $single);
You can learn more + examples in official wordpress documentation about custom fields.
You can use this through below code:
<?php echo get_post_meta($post_id, $key, true); ?>
Here your arguments must same as you have mention in function.php, while creating your custom field like as in:
<?php add_post_meta($post_id, $key, $single,true); ?>
Thanks.