Hello friends, Hope you are in good health and spirit. In today tutorial, I am going to share a very important tutorial with you which will help you during the development of your next site in WordPress, so keep your close eye in this tutorial as I am going to share how to add multiple values to a custom field in WordPress.
For adding a custom field in your WordPress post, first, you need to make custom field available for your post. For doing this click on the “Screens Options” and checked custom fields option.
In WordPress, you can be reused one custom field in the same post with different values. You need to select the same custom meta key multiple time. For more information see in below:
Do display the “mentions” custom field values in the front-end website, use the below code in your template page to get all values of your custom fields. Please change the “mentions” word with your custom field value.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | < ?php $mentions = get_post_meta($post->ID, 'mentions', false); if( count( $mentions ) != 0 ) { ?> <p>All Mentions:</p> <ul> < ?php foreach($mentions as $mentions) { echo '<li>'.$mentions.''; } ?> </ul> < ?php } else { // do nothing or do something as you want; } ?> |
Do you like & share this tutorial with your friends, and don’t forget to follow us on Facebook and Twitter to learn cool WordPress tutorials. Also subscribe my blog to get every future WordPress tips and tricks directly in you mailbox.
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.
Article Tags: how to add custom field wordpress, wordpress beginner, wordpress beginners, wordpress beginners tutorial, wordpress tutorial, wordpress tutorial for beginner, wordpress tutorial for beginners, wordpress tutorials, wordpress tutorials for beginners, wordpress tutorils